Skip to content

Commit a13d2fe

Browse files
committed
микрооптимизации, глобально
1 parent 10aa8e1 commit a13d2fe

File tree

12 files changed

+424
-425
lines changed

12 files changed

+424
-425
lines changed

src/OneScript.Core/Contexts/ClassBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private static bool MarkedAsContextMethod(MemberInfo member, bool includeDepreca
113113

114114
private static bool MarkedAsContextProperty(MemberInfo member, bool includeDeprecations = false)
115115
{
116-
return member.GetCustomAttributes(typeof(ContextPropertyAttribute), false).Any();
116+
return member.GetCustomAttributes(typeof(ContextPropertyAttribute), false).Length != 0;
117117
}
118118

119119
public ClassBuilder ExportConstructor(MethodInfo info)

src/OneScript.Language/SyntaxAnalysis/BslSyntaxWalker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ protected virtual void VisitTernaryOperation(BslSyntaxNode node)
324324

325325
protected virtual void VisitModuleBody(BslSyntaxNode codeBlock)
326326
{
327-
if(codeBlock.Children.Count > 0)
327+
if(codeBlock.Children.Count != 0)
328328
VisitCodeBlock(codeBlock.Children[0]);
329329
}
330330

src/OneScript.Language/SyntaxAnalysis/ConditionalDirectiveHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ private void MarkAsSolved()
297297

298298
private void PopBlock()
299299
{
300-
if (_blocks.Count > 0)
300+
if (_blocks.Count != 0)
301301
_blocks.Pop();
302302
else
303303
AddError(LocalizedErrors.DirectiveIsMissing("Если"));

src/OneScript.Language/SyntaxAnalysis/DefaultBslParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private void ParseModuleAnnotation()
123123
.Cast<ModuleAnnotationDirectiveHandler>()
124124
.ToList();
125125

126-
if (!annotationParser.Any())
126+
if (annotationParser.Count == 0)
127127
return;
128128

129129
while (_lastExtractedLexem.Type == LexemType.PreprocessorDirective)
@@ -1650,7 +1650,7 @@ private void AddError(CodeError err, bool doFastForward = true)
16501650

16511651
if (doFastForward)
16521652
{
1653-
if (_tokenStack.Count > 0)
1653+
if (_tokenStack.Count != 0)
16541654
SkipToNextStatement(_tokenStack.Peek());
16551655
else
16561656
SkipToNextStatement();

src/OneScript.Native/Compiler/MethodCompiler.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ protected override void VisitIfNode(ConditionNode node)
713713
{
714714
stack.Push(elif);
715715
}
716-
else if (stack.Count > 0)
716+
else if (stack.Count != 0)
717717
{
718718
var cond = stack.Pop();
719719

@@ -726,7 +726,7 @@ protected override void VisitIfNode(ConditionNode node)
726726
}
727727
}
728728

729-
while (stack.Count > 0)
729+
while (stack.Count != 0)
730730
{
731731
var elseIfNode = stack.Pop();
732732
VisitElseIfNode(elseIfNode);
@@ -1147,7 +1147,7 @@ protected override void VisitObjectProcedureCall(BslSyntaxNode node)
11471147
private IEnumerable<Expression> PrepareDynamicCallArguments(BslSyntaxNode argList)
11481148
{
11491149
return argList.Children.Select(passedArg =>
1150-
passedArg.Children.Count > 0
1150+
passedArg.Children.Count != 0
11511151
? ConvertToExpressionTree(passedArg.Children[0])
11521152
: Expression.Constant(BslSkippedParameterValue.Instance));
11531153
}
@@ -1414,7 +1414,7 @@ private List<Expression> PrepareCallArguments(BslSyntaxNode argList, ParameterIn
14141414
}
14151415

14161416
var parameters = argList.Children.Select(passedArg =>
1417-
passedArg.Children.Count > 0
1417+
passedArg.Children.Count != 0
14181418
? ConvertToExpressionTree(passedArg.Children[0])
14191419
: null).ToArray();
14201420

@@ -1523,7 +1523,7 @@ protected override void VisitNewObjectCreation(NewObjectNode node)
15231523
if (node.ConstructorArguments != default)
15241524
{
15251525
parameters = node.ConstructorArguments.Children.Select(passedArg =>
1526-
passedArg.Children.Count > 0 ?
1526+
passedArg.Children.Count != 0 ?
15271527
ConvertToExpressionTree(passedArg.Children[0]) :
15281528
Expression.Default(typeof(BslValue))).ToArray();
15291529
}

src/OneScript.Native/Compiler/StatementBlocksWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class StatementBlocksWriter
1818

1919
public void EnterBlock(JumpInformationRecord newJumpStates)
2020
{
21-
var current = _blocks.Count > 0 ? GetCurrentBlock() : null;
21+
var current = _blocks.Count != 0 ? GetCurrentBlock() : null;
2222
if (current != null)
2323
{
2424
newJumpStates.MethodReturn ??= current.MethodReturn;

src/OneScript.StandardLibrary/Collections/Indexes/CollectionIndex.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public CollectionIndex(IIndexCollectionSource source, IEnumerable<IValue> fields
4242

4343
internal bool CanBeUsedFor(IEnumerable<IValue> searchFields)
4444
{
45-
return _fields.Count > 0 && _fields.All(f => searchFields.Contains(f));
45+
return _fields.Count != 0 && _fields.All(f => searchFields.Contains(f));
4646
}
4747

4848
private CollectionIndexKey IndexKey(PropertyNameIndexAccessor source)

src/OneScript.StandardLibrary/CustomLineFeedStreamReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public int Read ()
5656
_buffer.Dequeue ();
5757
UpdateCharQueue ();
5858

59-
if (_buffer.Count > 0 && _buffer.Peek () == '\n') {
59+
if (_buffer.Count != 0 && _buffer.Peek () == '\n') {
6060
_buffer.Dequeue ();
6161
UpdateCharQueue ();
6262
}

src/OneScript.StandardLibrary/Tasks/BackgroundTasksManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void WaitCompletionOfTasks()
120120
var failedTasks = _tasks.Where(x => x.State == TaskStateEnum.CompletedWithErrors)
121121
.ToList();
122122

123-
if (failedTasks.Any())
123+
if (failedTasks.Count != 0)
124124
{
125125
throw new ParametrizedRuntimeException(
126126
Locale.NStr("ru = 'Задания завершились с ошибками';en = 'Tasks are completed with errors'"),

src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ This Source Code Form is subject to the terms of the
1212
using System.Linq;
1313
using System.Reflection;
1414
using System.Runtime.CompilerServices;
15-
using System.Text;
1615
using OneScript.Compilation;
1716
using OneScript.Compilation.Binding;
1817
using OneScript.Contexts;
@@ -126,7 +125,7 @@ private void HandleImportClause(AnnotationNode node)
126125

127126
private void CheckForwardedDeclarations()
128127
{
129-
if (_forwardedMethods.Count > 0)
128+
if (_forwardedMethods.Count != 0)
130129
{
131130
foreach (var item in _forwardedMethods)
132131
{
@@ -477,7 +476,7 @@ protected override void VisitContinueNode(LineMarkerNode node)
477476

478477
protected override void VisitReturnNode(BslSyntaxNode node)
479478
{
480-
if (node.Children.Count > 0)
479+
if (node.Children.Count != 0)
481480
{
482481
VisitExpression(node.Children[0]);
483482
AddCommand(OperationCode.MakeRawValue);
@@ -1085,15 +1084,15 @@ private void ExitTryBlocks()
10851084

10861085
private void PushTryNesting()
10871086
{
1088-
if (_nestedLoops.Count > 0)
1087+
if (_nestedLoops.Count != 0)
10891088
{
10901089
_nestedLoops.Peek().tryNesting++;
10911090
}
10921091
}
10931092

10941093
private void PopTryNesting()
10951094
{
1096-
if (_nestedLoops.Count > 0)
1095+
if (_nestedLoops.Count != 0)
10971096
{
10981097
_nestedLoops.Peek().tryNesting--;
10991098
}

0 commit comments

Comments
 (0)