@@ -38,7 +38,7 @@ public static AvatarManager Instance
3838 [ GeneratedRegex ( @"^(?:(\d+)\+)?(.+?)@.+\.github\.com$" ) ]
3939 private static partial Regex REG_GITHUB_USER_EMAIL ( ) ;
4040
41- private object _synclock = new object ( ) ;
41+ private readonly Lock _synclock = new ( ) ;
4242 private string _storePath ;
4343 private List < IAvatarHost > _avatars = new List < IAvatarHost > ( ) ;
4444 private Dictionary < string , Bitmap > _resources = new Dictionary < string , Bitmap > ( ) ;
@@ -144,8 +144,7 @@ public Bitmap Request(string email, bool forceRefetch)
144144 if ( _defaultAvatars . Contains ( email ) )
145145 return null ;
146146
147- if ( _resources . ContainsKey ( email ) )
148- _resources . Remove ( email ) ;
147+ _resources . Remove ( email ) ;
149148
150149 var localFile = Path . Combine ( _storePath , GetEmailHash ( email ) ) ;
151150 if ( File . Exists ( localFile ) )
@@ -179,8 +178,7 @@ public Bitmap Request(string email, bool forceRefetch)
179178
180179 lock ( _synclock )
181180 {
182- if ( ! _requesting . Contains ( email ) )
183- _requesting . Add ( email ) ;
181+ _requesting . Add ( email ) ;
184182 }
185183
186184 return null ;
@@ -200,10 +198,7 @@ public void SetFromLocal(string email, string file)
200198 if ( image == null )
201199 return ;
202200
203- if ( _resources . ContainsKey ( email ) )
204- _resources [ email ] = image ;
205- else
206- _resources . Add ( email , image ) ;
201+ _resources [ email ] = image ;
207202
208203 _requesting . Remove ( email ) ;
209204
0 commit comments