You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The implementation of FlexObject::TryGetMember uses a pattern of calling ContainsKey to determine if the underlying Dictionary<K,V> contains a key and then, if it does, uses the indexer to actually get the value. This is more costly than it needs to be as it has to hash the key twice and do two hash lookups into the dictionary:
just to see if it contains the key
to go get the value
A better pattern for this is to use the Dictionary<K,V>::TryGetValue method which will simultaneously look up the key and, if it exists, return the value via the out parameter while simultaneously returning a bool to indicate whether or not an entry with the specified key exists.
NOTE: this technically only impacts users that choose to use the dynamic programming model when working with FlexBox types.
The text was updated successfully, but these errors were encountered:
The implementation of
FlexObject::TryGetMember
uses a pattern of callingContainsKey
to determine if the underlyingDictionary<K,V>
contains a key and then, if it does, uses the indexer to actually get the value. This is more costly than it needs to be as it has to hash the key twice and do two hash lookups into the dictionary:A better pattern for this is to use the
Dictionary<K,V>::TryGetValue
method which will simultaneously look up the key and, if it exists, return the value via theout
parameter while simultaneously returning abool
to indicate whether or not an entry with the specified key exists.NOTE: this technically only impacts users that choose to use the dynamic programming model when working with
FlexBox
types.The text was updated successfully, but these errors were encountered: