Skip to content

Commit 25c0e3b

Browse files
committed
убраны лишние обращения к Linq
1 parent 71d1631 commit 25c0e3b

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/OneScript.StandardLibrary/Collections/ValueTable/ValueTable.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ public void GroupBy(IBslProcess process, string groupColumnNames, string aggrega
374374
}
375375
}
376376

377-
_rows.RemoveRange(new_idx, _rows.Count()-new_idx);
377+
_rows.RemoveRange(new_idx, _rows.Count - new_idx);
378378

379379
int i = 0;
380380
while (i < Columns.Count())
@@ -467,7 +467,7 @@ private int IndexByValue(BslValue item)
467467
throw RuntimeException.InvalidArgumentType();
468468
}
469469

470-
if (index < 0 || index >= _rows.Count())
470+
if (index < 0 || index >= _rows.Count)
471471
throw new RuntimeException("Значение индекса выходит за пределы диапазона");
472472
}
473473

@@ -489,7 +489,7 @@ public void Move(BslValue row, int offset)
489489

490490
int index_dest = index_source + offset;
491491

492-
if (index_dest < 0 || index_dest >= _rows.Count())
492+
if (index_dest < 0 || index_dest >= _rows.Count)
493493
throw RuntimeException.InvalidNthArgumentValue(2);
494494

495495
ValueTableRow tmp = _rows[index_source];
@@ -610,13 +610,13 @@ private List<ValueTableSortRule> GetSortRules(string Columns)
610610
foreach (string column in a_columns)
611611
{
612612
string[] description = column.Trim().Split(' ');
613-
if (description.Count() == 0)
613+
if (description.Length == 0)
614614
throw WrongColumnNameException();
615615

616616
ValueTableSortRule Desc = new ValueTableSortRule();
617617
Desc.Column = this.Columns.FindColumnByName(description[0]);
618618

619-
if (description.Count() > 1)
619+
if (description.Length > 1)
620620
{
621621
if (String.Compare(description[1], "DESC", true) == 0 || String.Compare(description[1], "УБЫВ", true) == 0)
622622
Desc.direction = -1;

src/OneScript.StandardLibrary/Collections/ValueTree/ValueTreeRowCollection.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ This Source Code Form is subject to the terms of the
77

88
using System;
99
using System.Collections.Generic;
10-
using System.Linq;
1110
using OneScript.Contexts;
1211
using OneScript.Exceptions;
1312
using OneScript.Execution;
@@ -72,7 +71,7 @@ public ValueTree Owner()
7271
[ContextMethod("Количество", "Count")]
7372
public override int Count()
7473
{
75-
return _rows.Count();
74+
return _rows.Count;
7675
}
7776

7877
/// <summary>
@@ -323,12 +322,12 @@ public void Move(BslValue row, int offset)
323322
else
324323
throw RuntimeException.InvalidArgumentType();
325324

326-
if (indexSource < 0 || indexSource >= _rows.Count())
325+
if (indexSource < 0 || indexSource >= _rows.Count)
327326
throw RuntimeException.InvalidArgumentValue();
328327

329-
int indexDestination = (indexSource + offset) % _rows.Count();
328+
int indexDestination = (indexSource + offset) % _rows.Count;
330329
while (indexDestination < 0)
331-
indexDestination += _rows.Count();
330+
indexDestination += _rows.Count;
332331

333332
ValueTreeRow tmp = _rows[indexSource];
334333

@@ -361,15 +360,15 @@ private List<ValueTreeSortRule> GetSortRules(string columns)
361360
foreach (string column in aColumns)
362361
{
363362
string[] description = column.Trim().Split(' ');
364-
if (description.Count() == 0)
363+
if (description.Length == 0)
365364
throw WrongColumnNameException();
366365

367366
ValueTreeSortRule desc = new ValueTreeSortRule();
368367
desc.Column = this.Columns.FindColumnByName(description[0]);
369368
if (desc.Column == null)
370369
throw WrongColumnNameException(description[0]);
371370

372-
if (description.Count() > 1)
371+
if (description.Length > 1)
373372
{
374373
if (String.Compare(description[1], "DESC", true) == 0 || String.Compare(description[1], "УБЫВ", true) == 0)
375374
desc.direction = -1;
@@ -393,7 +392,7 @@ private class RowComparator : IComparer<ValueTreeRow>
393392

394393
public RowComparator(IBslProcess process, List<ValueTreeSortRule> rules)
395394
{
396-
if (rules.Count() == 0)
395+
if (rules.Count == 0)
397396
throw RuntimeException.InvalidArgumentValue();
398397

399398
this._rules = rules;
@@ -415,7 +414,7 @@ public int Compare(ValueTreeRow x, ValueTreeRow y)
415414
int i = 0, r;
416415
while ((r = OneCompare(x, y, _rules[i])) == 0)
417416
{
418-
if (++i >= _rules.Count())
417+
if (++i >= _rules.Count)
419418
return 0;
420419
}
421420

0 commit comments

Comments
 (0)