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 EnumMap for callbacks #9

Merged
merged 2 commits into from
Feb 28, 2024
Merged

Use EnumMap for callbacks #9

merged 2 commits into from
Feb 28, 2024

Conversation

crisptrutski
Copy link
Collaborator

More typesafe and efficient - the map is backed by an array which uses the underlying int representation of each enum.

Small behavior change - the constructor will now throw an exception for unknown callback keys.

@tsmacdonald
Copy link
Contributor

If we're worried about safety, seems like we have to go whole hog and change the Clojure to use AstWalker$CallbackKey/Column instead of the keyword? That's not the prettiest though (even if you (def column-key AstWalker$...))

@tsmacdonald
Copy link
Contributor

Would also probably be nice to have a test for an invalid key

Base automatically changed from fold-tree to master February 28, 2024 17:06
@tsmacdonald
Copy link
Contributor

Small behavior change - the constructor will now throw an exception for unknown callback keys.

Not any more—now we have type safety to prevent that entirely.

Comment on lines +32 to +33
{(:column callback-keys) #(update %1 :columns conj (.getColumnName ^Column %2))
(:table callback-keys) #(update %1 :tables conj (.getName ^Table %2))}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nit: I'd rather do the key conversion in walk-query, to avoid duplication in later PRs.

@crisptrutski crisptrutski merged commit aba1c72 into master Feb 28, 2024
4 checks passed
@crisptrutski crisptrutski deleted the enum-map branch February 28, 2024 19:22
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