Re: faster strcpy()

Alexander Kjeldaas (astor@guardian.no)
Sun, 26 Apr 1998 23:03:03 +0200


On Sun, Apr 26, 1998, kwrohrer@enteract.com answered:
> And lo, Alexander Kjeldaas saith unto me:
> > Once upon a time, I was interested in compilers (guess I still am) and
> > it bothered me that languages often need null-terminated strings to be
> > compatible with the "C"-world. So I came up with the idea that in my
> > compiler, I would pad all strings to be a multiple of the word-size of
> > the machine. Then I would use between 4 and 1 null-bytes to terminate
> > the string. That way, I remained compatible with C, but in all the
> > str* routines, I only have to check one byte to know if I had come to
> > the end of the string.
> So what part of strtok's behavior would you break? (Assuming you could
> get the compiler to align all your strings right...)

break strtok?

> > It doesn't use any more memory either unless
> > you want to pack strings really tight, something you usually don't
> > want to do to avoid alignment problems.
> Unless, of course, you're dealing with substrings...
>

Substrings are ok if you align your reads. Also, in many languages
substrings have a different type than normal strings, so you can
implement optimized routines for normal strings that doesn't have to
deal with unaligned strings.

astor

-- 
 Alexander Kjeldaas, Guardian Networks AS, Trondheim, Norway
 http://www.guardian.no/

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu