fixed bugs related to index check and gc
This commit is contained in:
parent
c4ab4028ae
commit
5de3a94a46
@ -191,8 +191,6 @@ public class SaveParserEU4
|
||||
case TokenType.StringOrNumber:
|
||||
_stringBuilderPool.Return(tok.value!);
|
||||
return true;
|
||||
case TokenType.Equals:
|
||||
return true;
|
||||
case TokenType.BracketClose:
|
||||
return false;
|
||||
default:
|
||||
@ -232,13 +230,26 @@ public class SaveParserEU4
|
||||
private List<object> ParseList()
|
||||
{
|
||||
List<object> list = new();
|
||||
while (true)
|
||||
for (int i = 0; ; i++)
|
||||
{
|
||||
if (!_tokens.MoveNext())
|
||||
throw new Exception("Unexpected end of file");
|
||||
|
||||
ISearchExpression? searchExprNext = null;
|
||||
if (_searchExprCurrent != null
|
||||
&& !_searchExprCurrent.DoesMatch(new SearchArgs(i, string.Empty), out searchExprNext))
|
||||
{
|
||||
if(!SkipValue())
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
var searchExprPrev = _searchExprCurrent;
|
||||
_searchExprCurrent = searchExprNext;
|
||||
object? value = ParseValue();
|
||||
_searchExprCurrent = searchExprPrev;
|
||||
if (value is null)
|
||||
break;
|
||||
|
||||
list.Add(value);
|
||||
}
|
||||
|
||||
@ -294,7 +305,8 @@ public class SaveParserEU4
|
||||
if (_searchExprCurrent != null
|
||||
&& !_searchExprCurrent.DoesMatch(new SearchArgs(localIndex, keySB), out searchExprNext))
|
||||
{
|
||||
SkipValue();
|
||||
if(!SkipValue())
|
||||
throw new UnexpectedTokenException(_tokens.Current.Value);
|
||||
_stringBuilderPool.Return(keySB);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -86,7 +86,8 @@ public static class SearchExpressionCompiler
|
||||
ReadOnlySpan<char> remaining = default;
|
||||
if (partBeforePointLength < query.Length)
|
||||
remaining = query.Slice(partBeforePointLength + 1);
|
||||
if (part is "*") return new AnyMatchExpression(remaining.IsEmpty ? null : Compile(remaining));
|
||||
if (part is "*")
|
||||
return new AnyMatchExpression(remaining.IsEmpty ? null : Compile(remaining));
|
||||
|
||||
for (int j = 0; j < part.Length; j++)
|
||||
if (CharEqualsAndNotEscaped('*', part, j))
|
||||
|
||||
@ -109,7 +109,7 @@ public partial class Program
|
||||
}
|
||||
finally
|
||||
{
|
||||
GC.Collect(GC.MaxGeneration, GCCollectionMode.Aggressive, false, true);
|
||||
GC.Collect(GC.MaxGeneration, GCCollectionMode.Aggressive, true, true);
|
||||
}
|
||||
|
||||
return await ReturnResponseJson(ctx, meta);
|
||||
|
||||
@ -12,7 +12,6 @@ global using Directory = DTLib.Filesystem.Directory;
|
||||
global using File = DTLib.Filesystem.File;
|
||||
global using Path = DTLib.Filesystem.Path;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text.Encodings.Web;
|
||||
using DTLib.Dtsod;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user