Browse Source

Reused timeSpan variable from previous IF statement.

Re-utilized previous timespan variable. Minor optimization.
pull/1131/head
ericmck2000 GitHub 7 years ago
parent
commit
c3822347dd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions
  1. +4
    -5
      src/Discord.Net.Commands/Readers/TimeSpanTypeReader.cs

+ 4
- 5
src/Discord.Net.Commands/Readers/TimeSpanTypeReader.cs View File

@@ -34,13 +34,12 @@ namespace Discord.Commands
//First, try using the built-in TimeSpan.Parse. (Default Implementation)
if (TimeSpan.TryParseExact(data, _formats, CultureInfo.InvariantCulture, out var timeSpan))
return Task.FromResult(TypeReaderResult.FromSuccess(timeSpan));
//@ericmck2000 - Try using the regular TimeSpan.TryPrase. Greatly improves success rate.
else if (TimeSpan.TryParse(data, out var time))
return Task.FromResult(TypeReaderResult.FromSuccess(time));
//Try using the regular TimeSpan.TryPrase. Greatly improves success rate.
else if (TimeSpan.TryParse(data, out timeSpan))
return Task.FromResult(TypeReaderResult.FromSuccess(timeSpan));
//Else, return parse failed error.
else
{
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "Failed to parse TimeSpan"));
}
}
}
}

Loading…
Cancel
Save