mirror of
https://github.com/araddon/dateparse.git
synced 2025-10-22 14:26:16 +08:00
Further optimize ambiguous parsing
Optimize the common and special case where mm and dd are the same length, just swap in place. Avoids having to reparse the entire string. For this case, it's about 30% faster and reduces allocations by about 15%. This format is especially common, hence the reason to optimize for this case. Also fix the case for ambiguous date/time in the mm:dd:yyyy format.
This commit is contained in:
@@ -97,6 +97,13 @@ func BenchmarkParseAnyErrors(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkParseAmbiguous(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
MustParse("13/02/2014 04:08:09 +0000 UTC", RetryAmbiguousDateWithSwap(true))
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func BenchmarkParseDateString(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
|
Reference in New Issue
Block a user