Skip to content

Commit 626feed

Browse files
committed
Use ValueTask instead of Task
1 parent 40d4082 commit 626feed

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/LinkDotNet.Blog.Web/Features/Services/UserRecordService.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ private async ValueTask GetAndStoreUserRecordAsync()
6262

6363
private async ValueTask<int> GetIdentifierHashAsync()
6464
{
65-
var hasKey = await TryGetKey();
66-
if (hasKey)
65+
if (await TryGetKey())
6766
{
6867
var key = await localStorageService.GetItemAsync<Guid>("user");
6968
return key.GetHashCode();
@@ -74,12 +73,11 @@ private async ValueTask<int> GetIdentifierHashAsync()
7473
return id.GetHashCode();
7574
}
7675

77-
private async Task<bool> TryGetKey()
76+
private async ValueTask<bool> TryGetKey()
7877
{
7978
try
8079
{
81-
var hasKey = await localStorageService.ContainKeyAsync("user");
82-
return hasKey;
80+
return await localStorageService.ContainKeyAsync("user");
8381
}
8482
catch (Exception e)
8583
{
@@ -100,4 +98,4 @@ private string GetClickedUrl()
10098
var queryIndex = basePath.IndexOf('?');
10199
return queryIndex >= 0 ? basePath[..queryIndex] : basePath;
102100
}
103-
}
101+
}

0 commit comments

Comments
 (0)