Skip to content
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

Perf - FlexObject::TryGetMember double dictionary access #110

Closed
drub0y opened this issue Feb 14, 2018 · 1 comment
Closed

Perf - FlexObject::TryGetMember double dictionary access #110

drub0y opened this issue Feb 14, 2018 · 1 comment
Assignees

Comments

@drub0y
Copy link
Contributor

drub0y commented Feb 14, 2018

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:

  1. just to see if it contains the key
  2. 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.

@cleemullins
Copy link
Contributor

FlexObject has been removed by #425

ShYuPe pushed a commit to ShYuPe/botbuilder-dotnet that referenced this issue Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants