I have approximately 9 characters that all need to be replaced with
different characters. I know there are a number of ways to do this but what
is the most efficient?
- 1) Do a []byte walk and compare each byte and replace when found?
- Seems expensive if you have a 100 bytes in the []byte
- comes out to a max of 900 operations
- 2) Use byte.Replace() for each one?
- This seems to be about the same as #1 but seems like it makes a copy
so might use slightly more memory
- 3) Regex for each one?
- Seems like using a nuke to kill a flee
- Seems expensive in processing
- 4) Something I have not thought of?
- Specific algorithm to solve this?
The []byte slice it self likely will not be over 100 bytes, however they
may be be 10s of thousands of them.
Thanks,
Anthony Gruetzmacher
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.