xsoheilalizadeh / SnakeCaseConversion

The snake-case conversion benchmarks and extensions
MIT License
3 stars 1 forks source link

Zero Allocation #1

Open xsoheilalizadeh opened 5 years ago

xsoheilalizadeh commented 5 years ago

We still have 48B allocated how I can get zero-allocation?

|            Method |     Mean |     Error |    StdDev | Rank |  Gen 0 | Gen 1 | Gen 2 | Allocated |
|------------------ |---------:|----------:|----------:|-----:|-------:|------:|------:|----------:|
| ToSnakeCaseBySpan | 38.91 ns | 0.5575 ns | 0.4656 ns |    1 | 0.0153 |     - |     - |      48 B |

cc\ @hez2010

hez2010 commented 5 years ago

Maybe not, I thought twice and found that you have to allocate some memory on heap to pass the result to the caller. For now I think your ToSnakeCaseBySpan implementation is the best approach.