-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
bugSomething isn't workingSomething isn't workinghigh priorityThis issue requires immediate executionThis issue requires immediate execution
Description
CharSegment has bug in Equals method
Collections/csharp/Platform.Collections/Segments/CharSegment.cs
Lines 31 to 46 in 3643cf1
| public override bool Equals(Segment<char> other) | |
| { | |
| bool contentEqualityComparer(IList<char> left, IList<char> right) | |
| { | |
| // Base can be not an array, but still IList<char> | |
| if (Base is char[] baseArray && other.Base is char[] otherArray) | |
| { | |
| return baseArray.ContentEqualTo(Offset, Length, otherArray, other.Offset); | |
| } | |
| else | |
| { | |
| return left.ContentEqualTo(right); | |
| } | |
| } | |
| return this.EqualTo(other, contentEqualityComparer); | |
| } |
Fix it
Small example [use this sandbox and add property PublicDictionary to Walker4]:
/*
public IDictionary<CharSegment, long> PublicDictionary
{
get => Dictionary;
}
*/
var text = "aaaaaaaaaa";
var walker = new Walker4();
walker.WalkAll(text);
foreach (var l in walker.PublicDictionary)
{
foreach (var r in walker.PublicDictionary)
{
Console.WriteLine($"{l} == {r} ==> {l.Key.Equals(r.Key)}");
}
}Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinghigh priorityThis issue requires immediate executionThis issue requires immediate execution