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

core/avm1/avm2: Remove some static AvmStrings #19272

Merged
merged 7 commits into from
Jan 22, 2025

Conversation

Lord-McSweeney
Copy link
Collaborator

@Lord-McSweeney Lord-McSweeney commented Jan 18, 2025

Only about 120 static strings left in AVM2!

@Lord-McSweeney Lord-McSweeney force-pushed the avmstring-less-static branch 2 times, most recently from dab3010 to 1cde56d Compare January 19, 2025 04:25
@Lord-McSweeney Lord-McSweeney added A-core Area: Core player, where no other category fits T-refactor Type: Refactor / Cleanup labels Jan 19, 2025
@Lord-McSweeney Lord-McSweeney added the waiting-on-review Waiting on review from a Ruffle team member label Jan 20, 2025
self.base().name().unwrap_or_default()
}
fn name_optional(&self) -> Option<AvmString<'gc>> {
fn name(&self) -> Option<AvmString<'gc>> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

fwiw, from the API pov, it does make sense for a DO to always have a name, I think?
We'd need to check, but maybe it's possible that a DO is always suppposed to have some name (see set_default_instance_name)?

With that it mind, maybe eventually this still should return an AvmString and unwrap internally?

That said, I haven't tested any of this. I'm not suggesting to make the refactor bigger, rather want to avoid refactoring a dozen places to support an Option, which might be reverted in the future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, not all DOs have names. Graphics that were placed without a name, for example, don't have names. This was what caused the bug that #14463 fixed: you cannot look up a Graphic child with any name, even though if you somehow got access to a Graphic in AVM1 its .name would be an empty string.

) -> EventObject<'gc> {
let event_type = AvmString::new_utf8(activation.gc(), "netStatus");
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should do interning in most of these places, also for key.

core/src/avm2/globals.rs Outdated Show resolved Hide resolved
@Lord-McSweeney Lord-McSweeney force-pushed the avmstring-less-static branch 3 times, most recently from 8150ad3 to 0dd73d5 Compare January 21, 2025 20:09
core/src/avm2/globals.rs Outdated Show resolved Hide resolved
Lord-McSweeney added 7 commits January 21, 2025 17:14
Replaces the old `From<&'static WStr>` impl on AvmString
1. We no longer create a static AvmString to compare broadcast event types to to ensure they're a whitelisted event.
2. We now allocate an AvmString for looking up builtin classes before storing them on SystemClasses/SystemClassDefs.
@Lord-McSweeney Lord-McSweeney enabled auto-merge (rebase) January 22, 2025 01:14
@Lord-McSweeney Lord-McSweeney merged commit 85d92d3 into ruffle-rs:master Jan 22, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core player, where no other category fits T-refactor Type: Refactor / Cleanup waiting-on-review Waiting on review from a Ruffle team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants