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

problem_setting: speed up int validation #166

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Riolku
Copy link
Contributor

@Riolku Riolku commented Dec 29, 2024

Integer validation via regex is unfortunately very slow. For now, regex validation for floats will be kept, since custom validation would be very cumbersome, and problems with floats usually have high overhead regardless.

Integer validation via regex is unfortunately very slow. For now, regex
validation for floats will be kept, since custom validation would be
very cumbersome, and problems with floats usually have high overhead
regardless.
if (i < token.size() && token[i] == '-') {
++i;
}
if (i >= token.size() || token[i] < '1' || '9' < token[i]) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you should explicitly note that -0 is not a valid int, just in case some language considers it separate from 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This caveat is already in the documentation for readInt, should we add it here as a comment as well? I think the documentation is likely sufficient.

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.

2 participants