From 77a213b52a9fe320c7741a6da83cdb9a46e54c25 Mon Sep 17 00:00:00 2001 From: lipchev Date: Sat, 1 May 2021 02:56:54 +0300 Subject: [PATCH] fixing the (possible) concurrent modifications --- UnitsNet/CustomCode/UnitValueAbbreviationLookup.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/UnitsNet/CustomCode/UnitValueAbbreviationLookup.cs b/UnitsNet/CustomCode/UnitValueAbbreviationLookup.cs index a82d3f7faf..b076421848 100644 --- a/UnitsNet/CustomCode/UnitValueAbbreviationLookup.cs +++ b/UnitsNet/CustomCode/UnitValueAbbreviationLookup.cs @@ -1,4 +1,4 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. +// Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; @@ -32,7 +32,7 @@ internal List GetAbbreviationsForUnit(UnitType unit) where Uni internal List GetAbbreviationsForUnit(int unit) { if(!unitToAbbreviationMap.TryGetValue(unit, out var abbreviations)) - unitToAbbreviationMap[unit] = abbreviations = new List(); + return new List(0); return abbreviations.Distinct().ToList(); } @@ -44,7 +44,7 @@ internal List GetUnitsForAbbreviation(string abbreviation, bool ignoreCase) var map = ignoreCase ? lowerCaseAbbreviationToUnitMap : abbreviationToUnitMap; if(!map.TryGetValue(key, out List units)) - map[key] = units = new List(); + return new List(0); return units.Distinct().ToList(); }