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

Use RegexAst::Literal instead of const field on strings for fast enums #100

Merged
merged 4 commits into from
Dec 25, 2024

Conversation

hudson-ai
Copy link
Collaborator

No description provided.

@hudson-ai hudson-ai requested a review from mmoskal December 23, 2024 18:28
@hudson-ai hudson-ai changed the base branch from main to fast_enum December 23, 2024 18:28
@hudson-ai hudson-ai closed this Dec 23, 2024
@hudson-ai hudson-ai reopened this Dec 23, 2024
@hudson-ai hudson-ai changed the base branch from fast_enum to main December 23, 2024 18:30
@hudson-ai
Copy link
Collaborator Author

@mmoskal kind of messed up the base of this pr as I had to merge main back into yours

min_length: 0,
max_length: None,
regex: Some(RegexAst::Literal(s)),
} => &regex_syntax::escape(&serde_json::to_string(s).unwrap()),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the bit that makes it a bit tricky to do this for general string regexes -- json quoting

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll add AST node to escape. Shouldn't be hard.

@hudson-ai
Copy link
Collaborator Author

This takes the compile time of the schema in the linked issue #98 from 162ms to 44ms on my machine (still fairly slow, I suppose). Bundling everything into a lexeme probably really speeds up mask computation too :)

@hudson-ai hudson-ai mentioned this pull request Dec 25, 2024
@hudson-ai
Copy link
Collaborator Author

Closes #84

@hudson-ai hudson-ai merged commit cfbabf7 into guidance-ai:main Dec 25, 2024
1 check 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.

2 participants