Skip to content

Commit 491df6c

Browse files
committed
refactor: inline temporary variable
1 parent abae5f7 commit 491df6c

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

deadlock-dotnet-sdk/Domain/SafeFileHandleEx.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,10 +423,8 @@ public unsafe (string? v, Exception? ex) FileNameInfo
423423
if (!GetFileInformationByHandleEx(this, FILE_INFO_BY_HANDLE_CLASS.FileNameInfo, (FILE_NAME_INFO*)safeBuffer.DangerousGetHandle(), (uint)bufferLength))
424424
return fileNameInfo = (null, new Exception(errFailedMsg + "GetFileInformationByHandleEx encountered an error.", new Win32Exception()));
425425

426-
string tmp = new((char*)(safeBuffer.DangerousGetHandle() + sizeof(uint)), 0, (int)fni.FileNameLength / 2);
427-
428426
/* The string conversion copies the data to a new string in the managed heap before freeing safeBuffer and leaving this context. */
429-
return fileNameInfo = (tmp, null);
427+
return fileNameInfo = (new string((char*)(safeBuffer.DangerousGetHandle() + sizeof(uint)), 0, (int)fni.FileNameLength / 2), null);
430428
}
431429
else
432430
{

0 commit comments

Comments
 (0)