Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mini-optimization to updateEndTimes #1619

Merged
merged 2 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions music21/tree/fromStream.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,8 @@ def recurseGetTreeByClass(
if classList and element.classSet.isdisjoint(classList):
continue

endTime = flatOffset + element.duration.quarterLength

if useTimespans:
endTime = flatOffset + element.duration.quarterLength
pitchedTimespan = spans.PitchedTimespan(
element=element,
parentage=tuple(reversed(currentParentage)),
Expand Down
7 changes: 3 additions & 4 deletions music21/tree/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,13 @@ def updateEndTimes(self):

Returns None.
'''
pos = self.position
if isinstance(pos, SortTuple):
pos = pos.offset

try:
endTimeLow = self.payload.endTime
endTimeHigh = endTimeLow
except AttributeError: # elements do not have endTimes. do NOT mix elements and timespans.
pos = self.position
if isinstance(pos, SortTuple):
pos = pos.offset
endTimeLow = pos + self.payload.duration.quarterLength
endTimeHigh = endTimeLow

Expand Down