@@ -40,10 +40,13 @@ public static int IndexOfAny(this StringSegment value, char[] chars, int start,
40
40
return index ;
41
41
}
42
42
43
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
43
44
public static int IndexOfAny ( this StringSegment value , char [ ] chars , int start ) => value . IndexOfAny ( chars , start , value . Length - start ) ;
44
45
46
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
45
47
public static string Substring ( this StringSegment value , int pos ) => value . Substring ( pos , value . Length - pos ) ;
46
48
49
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
47
50
public static bool CompareIgnoreCase ( this StringSegment value , string text ) => value . Equals ( text , StringComparison . OrdinalIgnoreCase ) ;
48
51
49
52
public static StringSegment FromCsvField ( this StringSegment text )
@@ -56,6 +59,7 @@ public static StringSegment FromCsvField(this StringSegment text)
56
59
. Replace ( CsvConfig . EscapedItemDelimiterString , CsvConfig . ItemDelimiterString ) ) ;
57
60
}
58
61
62
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
59
63
public static bool ParseBoolean ( this StringSegment value )
60
64
{
61
65
if ( ! value . TryParseBoolean ( out bool result ) )
@@ -77,16 +81,19 @@ public static bool TryParseBoolean(this StringSegment value, out bool result)
77
81
return value . CompareIgnoreCase ( bool . FalseString ) ;
78
82
}
79
83
84
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
80
85
public static bool TryParseDecimal ( this StringSegment value , out decimal result )
81
86
{
82
87
return decimal . TryParse ( value . Value , NumberStyles . Float , CultureInfo . InvariantCulture , out result ) ;
83
88
}
84
89
90
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
85
91
public static bool TryParseFloat ( this StringSegment value , out float result )
86
92
{
87
93
return float . TryParse ( value . Value , NumberStyles . Float , CultureInfo . InvariantCulture , out result ) ;
88
94
}
89
95
96
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
90
97
public static bool TryParseDouble ( this StringSegment value , out double result )
91
98
{
92
99
return double . TryParse ( value . Value , NumberStyles . Float , CultureInfo . InvariantCulture , out result ) ;
@@ -144,56 +151,63 @@ private static string UnsignedMaxValueToIntType(ulong maxValue)
144
151
}
145
152
}
146
153
154
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
147
155
public static sbyte ParseSByte ( this StringSegment value )
148
156
{
149
157
return JsConfig . UseSystemParseMethods
150
158
? sbyte . Parse ( value . Value , CultureInfo . InvariantCulture )
151
159
: ( sbyte ) ParseSignedInteger ( value , sbyte . MaxValue , sbyte . MinValue ) ;
152
160
}
153
161
162
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
154
163
public static byte ParseByte ( this StringSegment value )
155
164
{
156
165
return JsConfig . UseSystemParseMethods
157
166
? byte . Parse ( value . Value , CultureInfo . InvariantCulture )
158
167
: ( byte ) ParseUnsignedInteger ( value , byte . MaxValue ) ;
159
168
}
160
169
170
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
161
171
public static short ParseInt16 ( this StringSegment value )
162
172
{
163
173
return JsConfig . UseSystemParseMethods
164
174
? short . Parse ( value . Value , CultureInfo . InvariantCulture )
165
175
: ( short ) ParseSignedInteger ( value , short . MaxValue , short . MinValue ) ;
166
176
}
167
177
178
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
168
179
public static ushort ParseUInt16 ( this StringSegment value )
169
180
{
170
181
return JsConfig . UseSystemParseMethods
171
182
? ushort . Parse ( value . Value , CultureInfo . InvariantCulture )
172
183
: ( ushort ) ParseUnsignedInteger ( value , ushort . MaxValue ) ;
173
184
}
174
185
175
-
186
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
176
187
public static int ParseInt32 ( this StringSegment value )
177
188
{
178
189
return JsConfig . UseSystemParseMethods
179
190
? int . Parse ( value . Value , CultureInfo . InvariantCulture )
180
191
: ( int ) ParseSignedInteger ( value , Int32 . MaxValue , Int32 . MinValue ) ;
181
192
}
182
193
194
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
183
195
public static uint ParseUInt32 ( this StringSegment value )
184
196
{
185
197
return JsConfig . UseSystemParseMethods
186
198
? uint . Parse ( value . Value , CultureInfo . InvariantCulture )
187
199
: ( uint ) ParseUnsignedInteger ( value , UInt32 . MaxValue ) ;
188
200
}
189
201
202
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
190
203
public static long ParseInt64 ( this StringSegment value )
191
204
{
192
205
return JsConfig . UseSystemParseMethods
193
206
? long . Parse ( value . Value , CultureInfo . InvariantCulture )
194
207
: ParseSignedInteger ( value , Int64 . MaxValue , Int64 . MinValue ) ;
195
208
}
196
209
210
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
197
211
public static ulong ParseUInt64 ( this StringSegment value )
198
212
{
199
213
return JsConfig . UseSystemParseMethods
0 commit comments