-
-
Notifications
You must be signed in to change notification settings - Fork 585
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
Dictionaries return copies of stored TypedArrays #1508
Comments
Does this happen when not using typed arrays? Given your example uses them only |
Arrays also copied, Images by reference. I have simplified the code above and made it testable. |
Typed arrays are already tracked here: So let's focus on dictionary, does it happen without using TypedArray at all? |
Please review my changes above. It affects Arrays and TypedArrays. Not Image. This is likely related to that other issue. It mentions an Array constructor that makes a copy. Perhaps Dictionary is triggering that constructor. The proposed PR only touches TypedArray so I'm guessing it won't fix this issue for Arrays in Dictionaries. |
would always trigger the constructor (and therefore a copy) since you are implicitly creating a typed array from an array can you try with arrays only something like :
|
@ajreckof Perhaps you saw an outdated version of this ticket. Please refresh and see that I tested TypedArray (copy), Array (copy) and Image (reference). edit: oh wait, my code for Array is wrong though. Let me redo that section. Ok, given that it's only related to TypedArray, I think this probably is just a duplicate. @AThousandShips do you think your PR will fix this ticket? |
I tested with gdscript and can't reproduce so this is gdextension only edit :
result
|
Feel free to try it out, I'm not sure, but it does sound like a duplicate as it doesn't affect Array |
The PR does fix the issue with TypedArray. I can use std::map for now until 4.3 is stable. Thank you both for the help. This was a frustrating journey. The function I was writing now processes 230k instances in .34 seconds and runs ~1700x faster with the PR and not having to writing back to the dictionary. |
Godot version
4.2.2-stable
godot-cpp version
godot-4.2.2-stable
System information
Windows 11/64, RTX 3070, Vulkan
Issue description
I am receiving copies of TypedArrays in gdextension when storing arrays indexed via Vector2i.
TypedArray: copy
Array: reference
Image: reference
I replaced the Godot dictionary with std::map and it works properly with Godot TypedArrays, so I am using that for now. Using a local map while building, then converting to a Godot dictionary for storage within a Godot resource.
The text was updated successfully, but these errors were encountered: