core: Use Vec::retain in Avm1TextFieldBinding::bind_variables#23940
core: Use Vec::retain in Avm1TextFieldBinding::bind_variables#23940SuchAFuriousDeath wants to merge 2 commits into
Conversation
|
Just a general note about this particular code (text variable binding): it's generally untested and buggy in Ruffle, it can easily introduce regressions. |
dfb9429 to
501c511
Compare
|
@kjarosh 🥺 |
| } | ||
| let mut text_fields = std::mem::take(activation.context.unbound_text_fields); | ||
|
|
||
| text_fields.retain(|field| !field.try_bind_text_field_variable(activation, false)); |
There was a problem hiding this comment.
This will change the order of elements, does it matter?
There was a problem hiding this comment.
Good question, I didn't consider that. From looking at the code, I don't see a reason why it should matter.
There was a problem hiding this comment.
For instance, try_bind_text_field_variable calls object.set which calls watchers. Can we add at least a test that checks the order of called watchers?
There was a problem hiding this comment.
I had Claude vibe out a test, see if it makes sense please, it does to me, but this isn't really an area of code I'm familiar with.
There was a problem hiding this comment.
Is the test failing with the previous code?
There was a problem hiding this comment.
No, I just checked. It doesn't depend on the order of iteration I guess.
There was a problem hiding this comment.
However, I think your claim here:
For instance,
try_bind_text_field_variablecallsobject.setwhich calls watchers.
Is wrong because try_bind_text_field_variable is called with false as the second argument and that results in watchers not being called, at least based on my understanding.
501c511 to
15047d0
Compare
|
@kjarosh 🥺 |
15047d0 to
97b64dd
Compare
Description
Just a tiny refactor, std::mem::take has to be used to satisfy the borrow checker.
SIDENOTE: The TODO talks about Vec::drain_filter, which got stabilized as Vec::extract_if, but retain is the better fit here, since there is no resulting iterator we have to consume.
Checklist