@@ -65,7 +65,6 @@ public class FontIconSet : ScriptableObject
6565 /// <returns><see langword="true"/> if icon name found, otherwise <see langword="false"/>.</returns>
6666 public bool TryGetGlyphIcon ( string iconName , out uint unicodeValue )
6767 {
68- unicodeValue = 0 ;
6968 return glyphIconsByName . TryGetValue ( iconName , out unicodeValue ) ;
7069 }
7170
@@ -77,15 +76,7 @@ public bool TryGetGlyphIcon(string iconName, out uint unicodeValue)
7776 /// <returns>Whether it was able to add this icon.</returns>
7877 public bool AddIcon ( string name , uint unicodeValue )
7978 {
80- if ( glyphIconsByName . ContainsValue ( unicodeValue ) )
81- {
82- return false ;
83- }
84- else
85- {
86- glyphIconsByName [ name ] = unicodeValue ;
87- return true ;
88- }
79+ return ! glyphIconsByName . ContainsValue ( unicodeValue ) && glyphIconsByName . TryAdd ( name , unicodeValue ) ;
8980 }
9081
9182 /// <summary>
@@ -95,15 +86,7 @@ public bool AddIcon(string name, uint unicodeValue)
9586 /// <returns>Whether it was able to find the name and remove it.</returns>
9687 public bool RemoveIcon ( string iconName )
9788 {
98- if ( glyphIconsByName . ContainsKey ( iconName ) )
99- {
100- glyphIconsByName . Remove ( iconName ) ;
101- return true ;
102- }
103- else
104- {
105- return false ;
106- }
89+ return glyphIconsByName . Remove ( iconName ) ;
10790 }
10891
10992 /// <summary>
@@ -118,16 +101,7 @@ public bool RemoveIcon(string iconName)
118101 /// <returns><see langword="true"/> if it was able to find and update the name.</returns>
119102 public bool UpdateIconName ( string oldName , string newName )
120103 {
121- if ( glyphIconsByName . ContainsKey ( oldName ) && ! glyphIconsByName . ContainsKey ( newName ) )
122- {
123- glyphIconsByName [ newName ] = glyphIconsByName [ oldName ] ;
124- glyphIconsByName . Remove ( oldName ) ;
125- return true ;
126- }
127- else
128- {
129- return false ;
130- }
104+ return glyphIconsByName . TryGetValue ( oldName , out uint unicodeValue ) && glyphIconsByName . TryAdd ( newName , unicodeValue ) && glyphIconsByName . Remove ( oldName ) ;
131105 }
132106
133107 /// <summary>
0 commit comments