We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2fa56e5 commit 087b952Copy full SHA for 087b952
BencodeNET.Net45/Bencode.cs
@@ -451,19 +451,12 @@ private static bool TryParseLongFast(string value, out long result)
451
if (length == 0)
452
return false;
453
454
- var startIndex = 0;
455
- var isNegative = false;
+ var isNegative = value[0] == '-';
+ var startIndex = isNegative ? 1 : 0;
456
457
- // Check if negative and set startIndex accordingly
458
- if (value[0] == '-')
459
- {
460
- // Cannot parse just '-'
461
- if (length == 1)
462
- return false;
463
-
464
- isNegative = true;
465
- startIndex = 1;
466
- }
+ // Cannot parse just '-'
+ if (isNegative && length == 1)
+ return false;
467
468
// Cannot parse string longer than long.MaxValue
469
if (length - startIndex > Int64MaxDigits)
0 commit comments