Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 7aa7b9d

Browse files
Merge pull request #1889 from KrzysztofCwalina/BugFix
Fixes bug #1887
2 parents 9ac2c1a + 49d5730 commit 7aa7b9d

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

src/System.Text.Encodings.Web/src/System/Text/Encodings/Web/UnicodeRanges.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,17 @@ private static UnicodeRange CreateEmptyRange(ref UnicodeRange range)
3232
{
3333
// If the range hasn't been created, create it now.
3434
// It's ok if two threads race and one overwrites the other's 'range' value.
35-
var newRange = new UnicodeRange(0, 0);
36-
Volatile.Write(ref range, newRange);
37-
return newRange;
35+
range = new UnicodeRange(0, 0);
36+
return range;
3837
}
3938

4039
[MethodImpl(MethodImplOptions.NoInlining)] // the caller should be inlined, not this method
4140
private static UnicodeRange CreateRange(ref UnicodeRange range, char first, char last)
4241
{
4342
// If the range hasn't been created, create it now.
4443
// It's ok if two threads race and one overwrites the other's 'range' value.
45-
Debug.Assert(last > first, "Code points were specified out of order.");
46-
var newRange = UnicodeRange.Create(first, last);
47-
Volatile.Write(ref range, newRange);
48-
return newRange;
44+
range = UnicodeRange.Create(first, last);
45+
return range;
4946
}
5047
}
5148
}

src/System.Text.Encodings.Web/tests/UnicodeRangesTests.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ public void Range_None()
2020
// Test 1: the range should be empty
2121
Assert.Equal(0, range.FirstCodePoint);
2222
Assert.Equal(0, range.Length);
23-
24-
// Test 2: calling the property multiple times should cache and return the same range instance
25-
UnicodeRange range2 = UnicodeRanges.None;
26-
Assert.Same(range, range2);
2723
}
2824

2925
[Fact]
@@ -203,10 +199,6 @@ public void Range_Unicode(ushort first, ushort last, string blockName)
203199
// Test 1: the range should span the range first..last
204200
Assert.Equal(first, range.FirstCodePoint);
205201
Assert.Equal(last, range.FirstCodePoint + range.Length - 1);
206-
207-
// Test 2: calling the property multiple times should cache and return the same range instance
208-
UnicodeRange range2 = (UnicodeRange)propInfo.GetValue(null);
209-
Assert.Same(range, range2);
210202
}
211203
}
212204
}

0 commit comments

Comments
 (0)