Skip to content

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