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

object allocation: attribute_names and attributes_map #143

Merged
merged 2 commits into from
Jun 10, 2019

Conversation

subvertallchris
Copy link
Contributor

Two things:

hash.keys creates a new array each time it's called but that list doesn't change that often, so this hangs onto it.

By making attributes_map a little uglier, we save one more array at the beginning and then another for each pairing of attribute and value! The overall object allocation improves performance, especially when a model has a large number of properties.

@subvertallchris subvertallchris changed the title Performance object allocation: attribute_names and attributes_map Apr 9, 2015
@subvertallchris
Copy link
Contributor Author

This may fix #134, too.

@aderyabin
Copy link

👍

@razum2um
Copy link

razum2um commented Feb 3, 2016

👍

@subvertallchris
Copy link
Contributor Author

This should probably be modified to not change the output of attribute!.

@cgriego cgriego self-assigned this May 26, 2019
@cgriego cgriego merged commit dea8ef2 into cgriego:master Jun 10, 2019
@cgriego
Copy link
Owner

cgriego commented Jun 10, 2019

This will be included in the next release. Thank you for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants