Skip to content

Commit 8208811

Browse files
committed
Minor performance improvements.
1 parent 28d34cd commit 8208811

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

VisualStudioSolutionSecrets/Commands/PushCommand.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,7 @@ public async Task<int> OnExecute()
8888

8989
if (isFileOk)
9090
{
91-
if (!secrets.ContainsKey(secretFile.ContainerName))
92-
{
93-
secrets.Add(secretFile.ContainerName, new Dictionary<string, string>());
94-
}
91+
secrets.TryAdd(secretFile.ContainerName, new Dictionary<string, string>());
9592
secrets[secretFile.ContainerName].Add(secretFile.Name, secretFile.Content);
9693
}
9794
else

VisualStudioSolutionSecrets/Commands/StatusCommand.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ public async Task<int> OnExecute()
5252

5353
foreach (string solutionFile in solutionFiles)
5454
{
55-
SolutionFile solution = new SolutionFile(solutionFile);
5655
await GetSolutionStatus(solutionFile);
5756
}
5857
}

VisualStudioSolutionSecrets/Encryption/Cipher.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ public void Init(Stream keyfile)
7474
private void GenerateEncryptionKey(byte[] data)
7575
{
7676
byte[] result;
77-
77+
#if NETCOREAPP3_1
7878
using var hashAlgorithm = SHA512.Create();
79-
8079
result = hashAlgorithm.ComputeHash(data);
80+
#else
81+
result = SHA512.HashData(data);
82+
#endif
8183
_key = Convert.ToBase64String(result);
8284

8385
AppData.SaveData(APP_DATA_FILENAME, new CipherAppData

VisualStudioSolutionSecrets/Repository/GistRepository.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,7 @@ private async Task CheckAccessToken()
498498
string? content = null;
499499
string cacheKey = $"{method} {uri}";
500500

501-
if (useCache && _requestsCache.ContainsKey(cacheKey))
502-
{
503-
content = _requestsCache[cacheKey];
504-
}
501+
_ = useCache && _requestsCache.TryGetValue(cacheKey, out content);
505502

506503
if (content == null)
507504
{

0 commit comments

Comments
 (0)