Use null-coalescing compound assignment for caches. (#295)
I didn't know this was possible before. It's neater so let's use it consistenly.
This commit is contained in:
Родитель
d8e194d278
Коммит
d21f426974
|
@ -30,7 +30,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.GenericData
|
|||
: result;
|
||||
}
|
||||
|
||||
public static GenericDataList Empty => s_empty ?? (s_empty = new GenericDataList(Array.Empty<GenericDataObject>()));
|
||||
public static GenericDataList Empty => s_empty ??= new GenericDataList(Array.Empty<GenericDataObject>());
|
||||
|
||||
public GenericDataObject this[int index] => _items[index];
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.GenericData
|
|||
? Empty
|
||||
: new GenericDataMap(items);
|
||||
|
||||
public static GenericDataMap Empty => s_empty ?? (s_empty = new GenericDataMap(new Dictionary<string, GenericDataObject>(0)));
|
||||
public static GenericDataMap Empty => s_empty ??= new GenericDataMap(new Dictionary<string, GenericDataObject>(0));
|
||||
|
||||
public GenericDataObject this[string key] => _items[key];
|
||||
|
||||
|
|
|
@ -4579,7 +4579,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
void EnsureColorThemePropertyExists(TranslationContext context, string bindingName, Color defaultValue)
|
||||
{
|
||||
// Create a theme property set if one hasn't been created yet.
|
||||
var themeProperties = _themePropertySet ?? (_themePropertySet = _c.CreatePropertySet());
|
||||
var themeProperties = _themePropertySet ??= _c.CreatePropertySet();
|
||||
|
||||
var defaultValueAsWinUIColor = Color(defaultValue);
|
||||
var defaultValueAsVector4 = Vector4(defaultValueAsWinUIColor);
|
||||
|
@ -4618,7 +4618,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.LottieToWinComp
|
|||
void EnsureScalarThemePropertyExists(string bindingName, double defaultValue)
|
||||
{
|
||||
// Create a theme property set if one hasn't been created yet.
|
||||
var themeProperties = _themePropertySet ?? (_themePropertySet = _c.CreatePropertySet());
|
||||
var themeProperties = _themePropertySet ??= _c.CreatePropertySet();
|
||||
|
||||
var defaultValueAsFloat = Float(defaultValue);
|
||||
|
||||
|
|
|
@ -23,13 +23,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie.WinCompData.Expressions
|
|||
/// Gets a simplified form of the expression. May be the same as this.
|
||||
/// </summary>
|
||||
// Expressions are immutable, so it's always safe to return a cached version.
|
||||
public T Simplified => _simplifiedExpressionCache ?? (_simplifiedExpressionCache = Simplify());
|
||||
public T Simplified => _simplifiedExpressionCache ??= Simplify();
|
||||
|
||||
/// <inheritdoc/>
|
||||
// Expressions are immutable, so it's always safe to return a cached version.
|
||||
// Always return the simplified version.
|
||||
public override string ToText()
|
||||
=> _expressionTextCache ?? (_expressionTextCache = Simplified.CreateExpressionText());
|
||||
public override string ToText() => _expressionTextCache ??= Simplified.CreateExpressionText();
|
||||
|
||||
protected virtual T Simplify() => (T)this;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче