tar-split icon indicating copy to clipboard operation
tar-split copied to clipboard

archive parsing: use strings.Trim...Func() instead of strings.Trim()

Open nalind opened this issue 3 years ago • 4 comments

When trimming string values as part of parsing them, use the string.Trim() variants that take a callback function instead of a string of characters to trim, so that they won't have to internally allocate a new helper structure on the heap every time we call them.

nalind avatar Dec 09 '21 16:12 nalind

Will this be necessary/useful in the future? https://github.com/golang/go/issues/46446 should make at least the single-character case more efficient using the simple code.

https://github.com/golang/go/commit/4002616f9a34410797e7bbff142c374a1de3ac6b also optimizes the multiple-ASCII-character case (although in that case it’s not obvious without measurement that the ASCII table approach is more efficient than Trim…Func for the very small strings used here).

mtrmac avatar Dec 10 '21 16:12 mtrmac

Will this be necessary/useful in the future? golang/go#46446 should make at least the single-character case more efficient using the simple code.

I would like for it to not be necessary in the future, of course.

nalind avatar Dec 10 '21 18:12 nalind

Looking now, neither of the changes is in the released Go 1.17. Go 1.18 seems to be scheduled for February.

mtrmac avatar Dec 10 '21 18:12 mtrmac

so, we could just wait until go1.18, and this improvement will be transparent and maintained by someone else?

vbatts avatar Dec 13 '21 15:12 vbatts

@nalind I realize I sat on this contribution :confused:
I value the contribution. :orange_heart: Now that we're up to go1.20, is this still needed?

vbatts avatar Mar 31 '23 02:03 vbatts

No, it isn't needed any more. Closing it.

nalind avatar Mar 31 '23 14:03 nalind