Skip to content

Replace duplicate dictionary lookups with TryGetValue and cached locals#4842

Merged
StefanOssendorf merged 1 commit intoMarimerLLC:mainfrom
SimonCropp:Replace-duplicate-dictionary-lookups-with-TryGetValue-and-cached-locals
Mar 15, 2026
Merged

Replace duplicate dictionary lookups with TryGetValue and cached locals#4842
StefanOssendorf merged 1 commit intoMarimerLLC:mainfrom
SimonCropp:Replace-duplicate-dictionary-lookups-with-TryGetValue-and-cached-locals

Conversation

@SimonCropp
Copy link
Copy Markdown
Contributor

  • UndoableBase: cache state[fieldName] in a local variable instead of looking it up three times during undo operations
  • UndoableBase/FieldDataManager: replace ContainsKey + GetRequiredValue with single TryGetValue call for _stateStack deserialization
  • FieldDataManager: replace ContainsKey + GetValue with single TryGetValue for child property lookup, also caching the concatenated key to avoid redundant string allocation
  • Remove unnecessary double cast in _stateStack deserialization

  - UndoableBase: cache state[fieldName] in a local variable instead of
    looking it up three times during undo operations
  - UndoableBase/FieldDataManager: replace ContainsKey + GetRequiredValue
    with single TryGetValue call for _stateStack deserialization
  - FieldDataManager: replace ContainsKey + GetValue with single TryGetValue
    for child property lookup, also caching the concatenated key to avoid
    redundant string allocation
  - Remove unnecessary double cast in _stateStack deserialization
Copy link
Copy Markdown
Contributor

@StefanOssendorf StefanOssendorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@StefanOssendorf StefanOssendorf merged commit 9ed48fd into MarimerLLC:main Mar 15, 2026
2 checks passed
@SimonCropp SimonCropp deleted the Replace-duplicate-dictionary-lookups-with-TryGetValue-and-cached-locals branch March 15, 2026 12:18
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

Successfully merging this pull request may close these issues.

2 participants