From dbaf2957387c5290a680c8918779683194137b1d Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Fri, 29 Jun 2018 17:47:53 +0200 Subject: [PATCH] Regex: reduce allocation slightly, add tests, code cleanup, add parser comments (#30632) * RegexParser & optionsstack ref * Add test coverage for Group.Synchronized * Adjust options mode test case * Add inline comment '#' test branch * Add comments * Replace manual ToLower calls by Span.ToLower * Make applicable fields readonly in parser * Change to Assert to reduce an if check in one branch * Code formatting * Avoid string allocation when IgnoreCase set Prefix patterns which are passed to RegexBoyerMoore are already lowercased by the parser. Remove the redundant ToLower() call and assert the patterns lowercase state * Add surrogate pair positive & negative tests * Add test cases for rtl anchor Signed-off-by: dotnet-bot --- .../System/Collections/Generic/ValueListBuilder.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/System.Private.CoreLib/shared/System/Collections/Generic/ValueListBuilder.cs b/src/System.Private.CoreLib/shared/System/Collections/Generic/ValueListBuilder.cs index 72da4a9e19..aea6052f03 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/Generic/ValueListBuilder.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/Generic/ValueListBuilder.cs @@ -21,7 +21,16 @@ namespace System.Collections.Generic _pos = 0; } - public int Length => _pos; + public int Length + { + get => _pos; + set + { + Debug.Assert(value >= 0); + Debug.Assert(value <= _span.Length); + _pos = value; + } + } public ref T this[int index] { -- 2.34.1