gosimple / slug

URL-friendly slugify with multiple languages support.
Mozilla Public License 2.0
1.17k stars 109 forks source link

Do the pre-defined substitions in one pass instead of two #5

Closed hectorj closed 9 years ago

hectorj commented 9 years ago

Merges language substitions with the default one at initialization, saving one pass of SubstituteRune

Benchmarks :

$ go test -bench Make -benchtime 5s
PASS
BenchmarkMakeShortAscii-8        2000000          4906 ns/op         656 B/op         20 allocs/op
BenchmarkMakeShort-8             1000000          5803 ns/op         672 B/op         18 allocs/op
BenchmarkMakeShortSymbols-8      1000000         11026 ns/op         912 B/op         29 allocs/op
BenchmarkMakeMediumAscii-8        500000         22402 ns/op        2736 B/op         47 allocs/op
BenchmarkMakeMedium-8             200000         31342 ns/op        4256 B/op         49 allocs/op
BenchmarkMakeLongAscii-8           30000        283138 ns/op       31072 B/op        372 allocs/op
$ go test -bench Make -benchtime 5s
PASS
BenchmarkMakeShortAscii-8        2000000          4591 ns/op         528 B/op         18 allocs/op
BenchmarkMakeShort-8             2000000          5000 ns/op         528 B/op         16 allocs/op
BenchmarkMakeShortSymbols-8      1000000          8985 ns/op         768 B/op         27 allocs/op
BenchmarkMakeMediumAscii-8        500000         18673 ns/op        2400 B/op         44 allocs/op
BenchmarkMakeMedium-8             300000         26313 ns/op        3536 B/op         45 allocs/op
BenchmarkMakeLongAscii-8           30000        265987 ns/op       27776 B/op        366 allocs/op
matrixik commented 9 years ago

Looks great. Thank you!