Less parsing, allocation & LINQ when splitting strings (#18048)

* Less parsing, allocation & LINQ when splitting strings

* Added unit test verifying refactoring of GetIdsFromPathReversed.

---------

Co-authored-by: Andy Butland <abutland73@gmail.com>
This commit is contained in:
Henrik
2025-01-31 15:22:57 +01:00
committed by GitHub
parent c64ec51305
commit def9bd096f
7 changed files with 47 additions and 30 deletions

View File

@@ -387,4 +387,12 @@ public class StringExtensionsTests
Assert.AreNotEqual(path, Path.GetFullPath(path));
}
}
[TestCase("1,2,3,4,5", "5,4,3,2,1")]
[TestCase("1,2,x,4,5", "5,4,2,1")]
public void GetIdsFromPathReversed(string input, string expected)
{
var ids = input.GetIdsFromPathReversed();
Assert.AreEqual(expected, string.Join(",", ids));
}
}