Skip to content
This repository was archived by the owner on Dec 12, 2024. It is now read-only.

Commit 20c0fe9

Browse files
use interlocked increment
1 parent eb07661 commit 20c0fe9

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

SwiftReflector/Naming/SequentialNamer.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Threading;
23
using SwiftReflector.Demangling;
34

45
#nullable enable
@@ -7,7 +8,6 @@ namespace SwiftReflector.Naming {
78
public class SequentialNamer {
89
int current;
910
string prefix;
10-
object nameLock = new object ();
1111

1212
public SequentialNamer (string prefix, int start = 0)
1313
{
@@ -17,9 +17,7 @@ public SequentialNamer (string prefix, int start = 0)
1717

1818
public string SafeName (string name)
1919
{
20-
lock (nameLock) {
21-
return CSSafeNaming.SafeIdentifier ($"{prefix}{name}{current++}");
22-
}
20+
return CSSafeNaming.SafeIdentifier ($"{prefix}{name}{Interlocked.Increment (ref current)}");
2321
}
2422
}
2523

@@ -32,7 +30,7 @@ public string SafeName (TLFunction tlf)
3230
{
3331
var module = tlf.Module.Name ?? "NoModule";
3432
var name = tlf.Name.Name ?? "Anonymous";
35-
return Name ($"_{module}_{name}");
33+
return SafeName ($"_{module}_{name}");
3634
}
3735
}
3836
}

0 commit comments

Comments
 (0)