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

Add method for getting the superclasses of an Instance to rbx_reflection #402

Merged
merged 6 commits into from
Mar 14, 2024

Conversation

Dekkonot
Copy link
Member

It's fairly common to need a list of superclasses for a class, so we should provide a method for it. This is an implementation.

It uses a HashSet for convenience. It's slightly more expensive than a Vec but provides an easy mechanism for checking if a class is in the returned set, so it feels worth it.

Copy link
Member

@kennethloeffler kennethloeffler left a comment

Choose a reason for hiding this comment

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

It uses a HashSet for convenience. It's slightly more expensive than a Vec but provides an easy mechanism for checking if a class is in the returned set, so it feels worth it.

Not sure if I agree - is Vec::contains any harder to use than HashSet::contains? And what's the maximum possible number of superclasses returned by this method?

@Dekkonot
Copy link
Member Author

I hadn't actually checked what the maximum amount was since it felt like it's either 1 or like 5 for most classes.

It turns out it is 6. With that in mind, I think a Vec is fine and I'm also going to update the starting capacity to just be 6.

rbx_reflection/src/database.rs Outdated Show resolved Hide resolved
@Dekkonot Dekkonot merged commit 55dd7e3 into rojo-rbx:master Mar 14, 2024
2 checks passed
@Dekkonot Dekkonot deleted the superclass-db branch March 14, 2024 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants