Skip to content

Commit 8ead6b9

Browse files
author
Oren (electricessence)
committed
Cleanup and update.
1 parent 5221c26 commit 8ead6b9

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

ThreadSafety.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -895,8 +895,8 @@ private static void WriteToInternal(string path, Action<FileStream> closure,
895895

896896
WriteTo(path, () =>
897897
{
898-
using (var fs = Unsafe.GetFileStream(path, retries, millisecondsRetryDelay, mode, access, share))
899-
closure(fs);
898+
using var fs = Unsafe.GetFileStream(path, retries, millisecondsRetryDelay, mode, access, share);
899+
closure(fs);
900900
},
901901
millisecondsTimeout, throwsOnTimeout);
902902
}
@@ -940,11 +940,9 @@ public static void AppendLineTo(string path, string text,
940940

941941
AppendTo(path, fs =>
942942
{
943-
using (var sw = new StreamWriter(fs))
944-
{
945-
sw.WriteLine(text);
946-
sw.Flush();
947-
}
943+
using var sw = new StreamWriter(fs);
944+
sw.WriteLine(text);
945+
sw.Flush();
948946
}, retries, millisecondsRetryDelay, millisecondsTimeout, throwsOnTimeout);
949947
}
950948

@@ -1048,8 +1046,8 @@ public static void ReadFrom(string path, Action<FileStream> closure,
10481046

10491047
ReadFrom(path, () =>
10501048
{
1051-
using (var fs = Unsafe.GetFileStreamForRead(path, retries, millisecondsRetryDelay))
1052-
closure(fs);
1049+
using var fs = Unsafe.GetFileStreamForRead(path, retries, millisecondsRetryDelay);
1050+
closure(fs);
10531051
},
10541052
millisecondsTimeout, throwsOnTimeout);
10551053
}
@@ -1069,8 +1067,8 @@ public static T ReadFrom<T>(string path, Func<FileStream, T> closure,
10691067

10701068
return ReadFrom(path, () =>
10711069
{
1072-
using (var fs = Unsafe.GetFileStreamForRead(path, retries, millisecondsRetryDelay))
1073-
return closure(fs);
1070+
using var fs = Unsafe.GetFileStreamForRead(path, retries, millisecondsRetryDelay);
1071+
return closure(fs);
10741072
}, millisecondsTimeout);
10751073
}
10761074

@@ -1080,8 +1078,8 @@ public static string ReadToString(string path, int retries = DEFAULT_RETRIES,
10801078
{
10811079
return ReadFrom(path, (fs) =>
10821080
{
1083-
using (var reader = new StreamReader(fs))
1084-
return reader.ReadToEnd();
1081+
using var reader = new StreamReader(fs);
1082+
return reader.ReadToEnd();
10851083
}, retries, millisecondsRetryDelay, millisecondsTimeout);
10861084
}
10871085

0 commit comments

Comments
 (0)