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

Avoid calling hyphenToCamelCase twice per note #1683

Merged
merged 1 commit into from
Jan 10, 2024

Conversation

alexandermorgan
Copy link
Contributor

hyphenToCamelCase from common.stringTools.py currently gets called twice for every note in a piece when importing an xml file. This can be avoided by passing an attributeName argument when using the _setAttributeFromTagText method to set the step and octave properties of notes.

With this change, when importing a file like:
score = corpus.parse('joplin/maple_leaf_rag.mxl', forceSource=True)
_setAttributeFromTagText goes from being called over 30k times to about 120 times. Since all the string manipulation in hyphenToCamelCase has no impact on one-word strings, all these avoided calls were unnecessary.

@coveralls
Copy link

Coverage Status

coverage: 93.031% (+0.001%) from 93.03%
when pulling dbe9aab on alexandermorgan:master
into 3941a7f on cuthbertLab:master.

Copy link
Member

@jacobtylerwalls jacobtylerwalls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Same spirit as 7a9a8f5.

@jacobtylerwalls jacobtylerwalls merged commit 0927e39 into cuthbertLab:master Jan 10, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants