File tree Expand file tree Collapse file tree 3 files changed +11
-21
lines changed Expand file tree Collapse file tree 3 files changed +11
-21
lines changed Original file line number Diff line number Diff line change @@ -174,12 +174,12 @@ public NumberValue Average()
174
174
/// <returns>The sum of the values in the vector.</returns>
175
175
public NumberValue Sum ( )
176
176
{
177
- var sum = NumberValue . Zero ;
177
+ var sum = 0.0 ;
178
178
179
- for ( var i = 0 ; i < Size ; i ++ )
180
- sum += array [ i ] ;
179
+ for ( var i = 0 ; i < array . Length ; i ++ )
180
+ sum += array [ i ] . Number ;
181
181
182
- return sum ;
182
+ return new NumberValue ( sum ) ;
183
183
}
184
184
185
185
/// <summary>
Original file line number Diff line number Diff line change @@ -21,9 +21,11 @@ private bool CreateKeywordToken()
21
21
22
22
var keyword = function [ ..endIndex ] ;
23
23
24
- var lowerKeyword = keyword . Length <= 1024
25
- ? stackalloc char [ keyword . Length ]
26
- : new char [ keyword . Length ] ;
24
+ // keyword shouldn't be bigger than the biggest valid keyword
25
+ if ( keyword . Length > "unassign" . Length )
26
+ return false ;
27
+
28
+ Span < char > lowerKeyword = stackalloc char [ keyword . Length ] ;
27
29
28
30
keyword . ToLowerInvariant ( lowerKeyword ) ;
29
31
Original file line number Diff line number Diff line change @@ -13,20 +13,8 @@ private bool CreateStringToken(char quote)
13
13
if ( function [ 0 ] != quote )
14
14
return false ;
15
15
16
- var endIndex = 1 ;
17
- var foundClosingQuote = false ;
18
- while ( endIndex < function . Length )
19
- {
20
- if ( function [ endIndex ] == quote )
21
- {
22
- foundClosingQuote = true ;
23
- break ;
24
- }
25
-
26
- endIndex ++ ;
27
- }
28
-
29
- if ( ! foundClosingQuote )
16
+ var endIndex = function [ 1 ..] . IndexOf ( quote ) + 1 ;
17
+ if ( endIndex == 0 )
30
18
throw new TokenizeException ( Resource . StringTokenizeException ) ;
31
19
32
20
var stringValue = function [ 1 ..endIndex ] ;
You can’t perform that action at this time.
0 commit comments