Skip to content

Commit

Permalink
Merge pull request dotnet#1889 from KrzysztofCwalina/BugFix
Browse files Browse the repository at this point in the history
Fixes bug #1887
  • Loading branch information
KrzysztofCwalina committed Jun 2, 2015
2 parents 9ac2c1a + 49d5730 commit 7aa7b9d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,17 @@ private static UnicodeRange CreateEmptyRange(ref UnicodeRange range)
{
// If the range hasn't been created, create it now.
// It's ok if two threads race and one overwrites the other's 'range' value.
var newRange = new UnicodeRange(0, 0);
Volatile.Write(ref range, newRange);
return newRange;
range = new UnicodeRange(0, 0);
return range;
}

[MethodImpl(MethodImplOptions.NoInlining)] // the caller should be inlined, not this method
private static UnicodeRange CreateRange(ref UnicodeRange range, char first, char last)
{
// If the range hasn't been created, create it now.
// It's ok if two threads race and one overwrites the other's 'range' value.
Debug.Assert(last > first, "Code points were specified out of order.");
var newRange = UnicodeRange.Create(first, last);
Volatile.Write(ref range, newRange);
return newRange;
range = UnicodeRange.Create(first, last);
return range;
}
}
}
8 changes: 0 additions & 8 deletions src/System.Text.Encodings.Web/tests/UnicodeRangesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ public void Range_None()
// Test 1: the range should be empty
Assert.Equal(0, range.FirstCodePoint);
Assert.Equal(0, range.Length);

// Test 2: calling the property multiple times should cache and return the same range instance
UnicodeRange range2 = UnicodeRanges.None;
Assert.Same(range, range2);
}

[Fact]
Expand Down Expand Up @@ -203,10 +199,6 @@ public void Range_Unicode(ushort first, ushort last, string blockName)
// Test 1: the range should span the range first..last
Assert.Equal(first, range.FirstCodePoint);
Assert.Equal(last, range.FirstCodePoint + range.Length - 1);

// Test 2: calling the property multiple times should cache and return the same range instance
UnicodeRange range2 = (UnicodeRange)propInfo.GetValue(null);
Assert.Same(range, range2);
}
}
}

0 comments on commit 7aa7b9d

Please sign in to comment.