Merge pull request #98301 from aaronp64/gdscript_validate_property
Some checks are pending
🔗 GHA / 📊 Static checks (push) Waiting to run
🔗 GHA / 🤖 Android (push) Blocked by required conditions
🔗 GHA / 🍏 iOS (push) Blocked by required conditions
🔗 GHA / 🐧 Linux (push) Blocked by required conditions
🔗 GHA / 🍎 macOS (push) Blocked by required conditions
🔗 GHA / 🏁 Windows (push) Blocked by required conditions
🔗 GHA / 🌐 Web (push) Blocked by required conditions
🔗 GHA / 🪲 Godot CPP (push) Blocked by required conditions

Avoid unnecessary `Dictionary` conversions in `GDScriptInstance::validate_property`
This commit is contained in:
Thaddeus Crews 2024-10-29 19:26:02 -05:00
commit 8004c7524f
No known key found for this signature in database
GPG Key ID: 62181B86FE9E5D84

View File

@ -1862,14 +1862,14 @@ Variant::Type GDScriptInstance::get_property_type(const StringName &p_name, bool
} }
void GDScriptInstance::validate_property(PropertyInfo &p_property) const { void GDScriptInstance::validate_property(PropertyInfo &p_property) const {
Variant property = (Dictionary)p_property;
const Variant *args[1] = { &property };
const GDScript *sptr = script.ptr(); const GDScript *sptr = script.ptr();
while (sptr) { while (sptr) {
if (likely(sptr->valid)) { if (likely(sptr->valid)) {
HashMap<StringName, GDScriptFunction *>::ConstIterator E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._validate_property); HashMap<StringName, GDScriptFunction *>::ConstIterator E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._validate_property);
if (E) { if (E) {
Variant property = (Dictionary)p_property;
const Variant *args[1] = { &property };
Callable::CallError err; Callable::CallError err;
Variant ret = E->value->call(const_cast<GDScriptInstance *>(this), args, 1, err); Variant ret = E->value->call(const_cast<GDScriptInstance *>(this), args, 1, err);
if (err.error == Callable::CallError::CALL_OK) { if (err.error == Callable::CallError::CALL_OK) {