Skip to content

Commit 0f7bb37

Browse files
author
Maksim Volkau
committed
ImToolsSmallList consistent method naming
1 parent 10b21cb commit 0f7bb37

5 files changed

Lines changed: 17 additions & 17 deletions

File tree

src/FastExpressionCompiler.LightExpression/Expression.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5038,7 +5038,7 @@ public class BlockExpression : Expression, IArgumentProvider
50385038
public override Type Type => Result.Type;
50395039
public virtual IReadOnlyList<ParameterExpression> Variables => Tools.Empty<ParameterExpression>();
50405040
public SmallList<Expression, Stack2<Expression>, NoArrayPool<Expression>> Expressions;
5041-
public Expression Result => Expressions.GetLastSurePresentItem(); // todo: @check what if no expressions?
5041+
public Expression Result => Expressions.GetLastSurePresentRef(); // todo: @check what if no expressions?
50425042
public virtual int ArgumentCount => 0;
50435043
public virtual Expression GetArgument(int index) => throw new NotImplementedException();
50445044
internal BlockExpression(in SmallList<Expression, Stack2<Expression>, NoArrayPool<Expression>> expressions) =>

src/FastExpressionCompiler/FastExpressionCompiler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ public void PushBlockAndConstructLocalVars(IReadOnlyList<PE> blockVarExprs, ILGe
806806
private void PushVarInBlockMap(ParameterExpression pe, ushort blockIndex, ushort varIndex)
807807
{
808808
ref var blocks = ref _varInBlock.Map.AddOrGetValueRef(pe, out _);
809-
if (blocks.Count == 0 || (blocks.GetLastSurePresentItem() >>> 16) != blockIndex)
809+
if (blocks.Count == 0 || (blocks.GetLastSurePresentRef() >>> 16) != blockIndex)
810810
blocks.Add((uint)(blockIndex << 16) | varIndex);
811811
}
812812

@@ -818,7 +818,7 @@ public void PopBlock()
818818
{
819819
ref var varBlocks = ref _varInBlock.Map.GetSurePresentEntryRef(i);
820820
if (varBlocks.Value.Count == _blockCount)
821-
varBlocks.Value.RemoveLastSurePresentItem();
821+
varBlocks.Value.RemoveLastSurePresent();
822822
}
823823
--_blockCount;
824824
}
@@ -835,7 +835,7 @@ public int GetDefinedLocalVarOrDefault(ParameterExpression varParamExpr)
835835
{
836836
ref var blocks = ref _varInBlock.Map.TryGetValueRef(varParamExpr, out var found);
837837
return found && blocks.Count != 0 // rare case with the block count 0 may occur when we collected the block and vars, but not yet defined the variable for it
838-
? (int)(blocks.GetLastSurePresentItem() & ushort.MaxValue)
838+
? (int)(blocks.GetLastSurePresentRef() & ushort.MaxValue)
839839
: -1;
840840
}
841841
}

src/FastExpressionCompiler/ImTools.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ public interface ISmallList<T> : IIndexed<T>, IEnumerable<T>
746746
int TryGetIndex<TEq>(in T item, TEq eq = default) where TEq : struct, IEq<T>;
747747

748748
/// <summary>Removes the last item from the list. List should not be empty.</summary>
749-
void RemoveLastSurePresentItem();
749+
void RemoveLastSurePresent();
750750

751751
/// <summary>Clears the list.</summary>
752752
void Clear();
@@ -905,15 +905,15 @@ public void FreePooled()
905905
/// <summary>Returns last present item ref, assumes that the list is not empty!</summary>
906906
[UnscopedRef]
907907
[MethodImpl((MethodImplOptions)256)]
908-
public ref T GetLastSurePresentItem()
908+
public ref T GetLastSurePresentRef()
909909
{
910910
Debug.Assert(_count > 0, "Expecting that the list is not empty");
911911
return ref GetSurePresentRef(_count - 1);
912912
}
913913

914914
/// <summary>Removes the last item from the list aka the Stack Pop. Assumes that the list is not empty!</summary>
915915
[MethodImpl((MethodImplOptions)256)]
916-
public void RemoveLastSurePresentItem()
916+
public void RemoveLastSurePresent()
917917
{
918918
Debug.Assert(_count > 0, "SmallList.RemoveLastSurePresentItem: Expecting that the list is not empty");
919919
GetSurePresentRef(_count - 1) = default;

test/FastExpressionCompiler.IssueTests/Issue499_InvalidProgramException_for_Sorting_and_comparison_function.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public void Run(TestRun t)
2424
}
2525

2626
// Reproduces the sorting use-case from https://github.com/dadhi/FastExpressionCompiler/issues/499
27-
// using the same nested-loop pattern as SortCompiler.Compile but minimised to a plain int[].
27+
// using the same nested-loop pattern as SortCompiler.Compile but minimized to a plain int[].
2828
// The outer loop drives a quicksort-style partition; two inner loops advance the i/j cursors.
2929
public void Quicksort_partition_with_nested_loops(TestContext t)
3030
{
@@ -108,7 +108,7 @@ public void Quicksort_partition_with_nested_loops(TestContext t)
108108

109109
// Reproduces the comparison-function use-case from https://github.com/dadhi/FastExpressionCompiler/issues/499
110110
// using the same Return(label, value) / goto pattern as SortCompiler.CompileComparisonFunction
111-
// but minimised to a plain int comparison (DESC order, like the original failing test).
111+
// but minimized to a plain int comparison (DESC order, like the original failing test).
112112
public void Comparison_function_with_goto_labels(TestContext t)
113113
{
114114
var left = Parameter(typeof(int), "left");

test/FastExpressionCompiler.UnitTests/ArithmeticOperationsTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ public int Run()
2222
Can_sum_signed_bytes_converted_to_ints();
2323
Can_sum_all_primitive_numeric_types_that_define_binary_operator_add();
2424
Can_not_sum_with_checked_overflow();
25-
Can_substract_all_primitive_numeric_types_that_define_binary_operator_substract();
26-
Can_substract_with_unchecked_overflow();
27-
Can_not_substract_with_checked_overflow();
25+
Can_subtract_all_primitive_numeric_types_that_define_binary_operator_subtract();
26+
Can_subtract_with_unchecked_overflow();
27+
Can_not_subtract_with_checked_overflow();
2828
Can_modulus();
2929
Can_bit_or_1();
3030
Can_bit_and_1();
@@ -37,7 +37,7 @@ public int Run()
3737
Can_divide_bytes();
3838
Can_divide_signed_bytes();
3939
Can_sum_decimal_numbers();
40-
Can_substract_decimal_numbers();
40+
Can_subtract_decimal_numbers();
4141
Can_multiply_decimal_numbers();
4242
Can_divide_decimal_numbers();
4343
Can_divide_all_primitive_numeric_types_that_define_binary_operator_divide();
@@ -135,7 +135,7 @@ void AssertSub<T, R>(T x, T y, R expected, bool convertArgsToResult = false)
135135
}
136136

137137

138-
public void Can_substract_all_primitive_numeric_types_that_define_binary_operator_substract()
138+
public void Can_subtract_all_primitive_numeric_types_that_define_binary_operator_subtract()
139139
{
140140
AssertSub<byte, int>(5, 1, 4, true);
141141
AssertSub<sbyte, int>(5, 1, 4, true);
@@ -150,13 +150,13 @@ public void Can_substract_all_primitive_numeric_types_that_define_binary_operato
150150
}
151151

152152

153-
public void Can_substract_with_unchecked_overflow()
153+
public void Can_subtract_with_unchecked_overflow()
154154
{
155155
AssertSub<int, int>(int.MinValue, 1, int.MaxValue);
156156
}
157157

158158

159-
public void Can_not_substract_with_checked_overflow()
159+
public void Can_not_subtract_with_checked_overflow()
160160
{
161161
var a = Parameter(typeof(int), "a");
162162
var b = Parameter(typeof(int), "b");
@@ -385,7 +385,7 @@ public void Can_sum_decimal_numbers()
385385
}
386386

387387

388-
public void Can_substract_decimal_numbers()
388+
public void Can_subtract_decimal_numbers()
389389
{
390390
AssertSub(2.0m, 1.0m, 2.0m - 1.0m);
391391
}

0 commit comments

Comments
 (0)