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