F
Flow2mo ago
Giovanni S

Giovanni S | Flow (2024-04-05)

How computationally expensive is calling someArray.length - does it require enumeration over the entire array or is it constant time?
7 Replies
Needle
Needle2mo ago
I've created a thread for your message. Please continue any relevant discussion in this thread. You can rename this thread using /title <new title> If this is a technical question that others may benefit from, considering also asking it on Stackoverflow: https://stackoverflow.com/questions/ask?tags=onflow-cadence
turbolent
turbolent2mo ago
It's constant time, it's cheap
Giovanni S
Giovanni S2mo ago
Is that also the case for dictionaries? I thought there were previously concerns about computation required to get someMapping.length
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Giovanni S
Giovanni S2mo ago
Amazing, thank you. I'll need to play around with it
turbolent
turbolent2mo ago
No, AFAIK the length is stored in the root. cc @Faye | Flow
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View