Skip to content

Commit

Permalink
minor speed optimization in CoordString.getX/Y/Z
Browse files Browse the repository at this point in the history
see issue #43

~5% improvement
  • Loading branch information
njwilson23 committed Jun 30, 2017
1 parent 2a58654 commit 4cf6917
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions karta/vector/coordstring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,19 @@ cdef class CoordString:
return True

cdef double getX(self, int index):
if self.ring and index == self.length:
if index == self.length and self.ring:
index = 0
return self.coords[index*self.rank]

cdef double getY(self, int index):
if self.ring and index == self.length:
if index == self.length and self.ring:
index = 0
return self.coords[index*self.rank+1]

cdef double getZ(self, int index):
if self.rank != 3:
return NAN
if self.ring and index == self.length:
if index == self.length and self.ring:
index = 0
return self.coords[index*self.rank+2]

Expand Down

0 comments on commit 4cf6917

Please sign in to comment.