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

Only build comment strings on violation #7

Open
togaen opened this issue Oct 19, 2020 · 1 comment
Open

Only build comment strings on violation #7

togaen opened this issue Oct 19, 2020 · 1 comment
Assignees

Comments

@togaen
Copy link
Contributor

togaen commented Oct 19, 2020

The code currently construction comment strings regardless of whether a contract violation has occurred. This can have significant performance implications. Ideally the string object should only be constructed on violation. We could alternatively preallocate all string messages, but that then makes it impossible to add context-specific information.

@togaen
Copy link
Contributor Author

togaen commented Oct 21, 2020

One possibility is to make a macro similar to the CONTRACT_COMMENT macro that takes a boolean condition and comment string and to rewrite to a ternary that conditionally yields either an empty string or the comment string based on the boolean condition. Some quick benchmarking indicates this is slightly less performant than the CONTRACT_COMMENT approach (on the order of 2-3%), but maybe it's useful enough to add.

@togaen togaen self-assigned this Mar 15, 2021
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

No branches or pull requests

1 participant