Replies: 1 comment
-
I don't believe there are currently APIs that specifically optimize this case. So I think the best you can do right now is pretty much standard JS optimization e.g. const parts_files: PackedStringArray = DirAccess.get_files_at(PARTS_DATA);
const length = parts_files.size();
let parts: string[] = new Array(length);
for (let i = 0; i < length; ++i) {
const filePath = parts_files.get(i);
parts[i] = filePath;
} I'm not sure how much benefit you get by potentially eliminating an underlying buffer resize. v8 applies different strategies internally depending on array length etc. However, you will receive a more measurable gain by calling |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi All,
I am looking for best way to convert GArray/PackedStringArray, because feel JS array has more flexibility for the array operation.
I've seen the docs https://godotjs.github.io/documentation/godot-js-scripts/bindings/ shows how to covert JS Array/Object to GArray/GDictionary, but didn't see an example how it can convert it back to js array/object.
I wonder does GodotJs has built-in convert function ?
Currently I did it with this way, but feel it's a bit low efficient
But i think might be there is better way to do it natively?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions