#46939: refactor: add gin_helper::Dictionary::ValueOrDefault()
Merged
Description of Change
Add gin_helper::Dictionary::ValueOrDefault()
, a convenience function for using a default value if the specified key isn't in the dictionary.
tldr:
- int foo = 23;
- options.Get(options::kFoo &foo);
+ const int foo = options.ValueOrDefault(options::kFoo, 23);
This is an improvement because it's more const
-friendly and more concise.
In some cases, you can also eliminate the variable altogether:
- int foo = 23;
- options.Get(options::kFoo, &foo);
- dict.Set("foo", foo);
+ dict.Set("foo", options.ValueOrDefault(options::kFoo, 23));
Checklist
- PR description included and stakeholders cc'd
-
npm test
passes - PR release notes describe the change in a way relevant to app developers, and are capitalized, punctuated, and past tense.
Release Notes
Notes: none.
Backports
35-x-y
MergedPR Number
#47203Merged At
May 22, 2025, 5:35:57 AM
Released In
v35.5.0Release Date
May 28, 2025, 11:03:13 AM
36-x-y
MergedPR Number
#46968Merged At
May 6, 2025, 6:50:12 PM
Released In
v36.2.0Release Date
May 7, 2025, 11:02:14 AM
37-x-y
MergedPR Number
#46969Merged At
May 6, 2025, 7:11:30 PM
Released In
v37.0.0-alpha.4Release Date
May 12, 2025, 8:31:44 AM
Semver Impact
Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron