diff options
author | David Briscoe <43559+idbrii@users.noreply.github.com> | 2023-07-23 02:43:22 -0700 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-02-09 12:08:12 +0100 |
commit | 9cbc4026ee1373633ad920712c300e39ae154fbd (patch) | |
tree | a701670a8b4c8dcb4b6ed9894dd67bfc9afb0f83 /modules/gdscript/gdscript_cache.cpp | |
parent | 6588a4a29af1621086feac0117d5d4d37af957fd (diff) | |
download | redot-engine-9cbc4026ee1373633ad920712c300e39ae154fbd.tar.gz |
doc: Clarify when to construct a StringName ahead of time
Fix docs don't give justification for manual construction.
Clarify how to apply manual StringName construction as an
optimization and that "string intern" means "work at parse time".
There are several godot-demo-projects (including 3d/platformer) that
incorrectly use StringName literals (they use & literals instead of just
passing strings), so clearly this is confusing.
AThousandShips did a disassembly test to prove it automatically converts
constant strings to StringName for annotated functions:
func do_test(_var: StringName, _var2: String):
pass
func test():
do_test("abc", "def")
Yields:
Disassembling do_test(_var, _var2)
0: line 2: pass
2: == END ==
Disassembling test()
0: line 5: do_test("abc", "def")
2: call self.do_test(const(&"abc"), const("def"))
10: assign stack(3) = false
12: == END ==
It also happens with built-in functions such as those of Input.
Diffstat (limited to 'modules/gdscript/gdscript_cache.cpp')
0 files changed, 0 insertions, 0 deletions