jwt
jwt copied to clipboard
no need for string slice and call to strings.join
this cleans up the code a bit and avoids unnecessary memory allocations
and avoids unnecessary memory allocations
Would it be possible to add a benchmark to demonstrate that change indeed reduces allocations?
@moneszarrugh @AlexanderYastrebov There is an example on #34 (which is stale but I came back to take a look at and should be merged in the meantime before this one goes to the same code)
@moneszarrugh @AlexanderYastrebov There is an example on #34 (which is stale but I came back to take a look at and should be merged in the meantime before this one goes to the same code)
Sorry for keeping this stale, as I have no freetime to benchmark and test it. If anyone is interested in adding these feel free to do it.
@moneszarrugh @AlexanderYastrebov There is an example on #34 (which is stale but I came back to take a look at and should be merged in the meantime before this one goes to the same code)
Sorry for keeping this stale, as I have no freetime to benchmark and test it. If anyone is interested in adding these feel free to do it.
So I did some checking and in fact it does not have less allocations, however, the code is cleaner and easier to understand and thus it makes sense to accept it.
Before:
BenchmarkHS512Signing-8 1604331 715.2 ns/op 1777 B/op 26 allocs/op
After:
BenchmarkHS512Signing-8 1616665 702.9 ns/op 1777 B/op 26 allocs/op
Thanks @oxisto