Always true. But hard to believe that a map could be faster. The array will
be on the stack.
On Thu, Aug 30, 2018 at 9:31 AM Marvin Renich wrote:
> * Michael Jones [180830 11:44]:
> > The task to "translate a string through a table" is common. It is a
> single
> > computer instruction (TR) in t
* Michael Jones [180830 11:44]:
> The task to "translate a string through a table" is common. It is a single
> computer instruction (TR) in the IBM 360 and was extended over time with
> related instructions for conversion in and out of UTF-8, testing before and
> after translation, and expanded ch
The task to "translate a string through a table" is common. It is a single
computer instruction (TR) in the IBM 360 and was extended over time with
related instructions for conversion in and out of UTF-8, testing before and
after translation, and expanded character sizes. Tamás Gulácsi's approach
w
* Tamás Gulácsi [180830 01:17]:
> An even faster lookup is creating a [256]byte array for the replacements,
> having the 9 replacements candidates _position_ having the replacements,
> all others the identity:
>
> // prepare the lookup table
> var a [256]byte
> for i := 0; i<256; i++ {
> a[i]
An even faster lookup is creating a [256]byte array for the replacements,
having the 9 replacements candidates _position_ having the replacements,
all others the identity:
// prepare the lookup table
var a [256]byte
for i := 0; i<256; i++ {
a[i] = i
}
a[37] = '-'
a[129] = '-'
...
// replace t
Makes sense. Best I am going to get is a linear search w/ a divide and
conquer if I want to speed it up. Thanks needed the sounding board and feed
back.
Thanks,
Anthony
On Wednesday, August 29, 2018 at 8:16:44 PM UTC-7, Daniela Petruzalek wrote:
>
> Do you have an example?
>
> I'm assuming tha
Do you have an example?
I'm assuming that the replacement is one character for another. (ie.: not
one character being replaced by a group of characters).
Regarding to finding the positions to replace you can't beat O(n)
complexity as you must look at least once at every character on the source
st
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 []byt