[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: 64 bit->48 bit pointer hacks...



> A 7 byte string takes up 64 bits.

If the flag could live at the correct end of the bytes:

if( isShortString() ){
  return mySevenBytes & 0xfffffff0;
}

;-)

With respect to the rest of the comments, I know one could make such an
"optimization" very ugly and not well behaved...  I was just doing the
mental exercise of "is there a safe way to do it" and not coming up with a
satisfactory answer.  Writing flags into the address oneself isn't a good
idea, so then I was just wondering if it's possible despite the "goodness"
of the idea.

For short strings, allocating 8 bytes to point at a couple of characters
just seems wrong ;-) So if "isShortString()" could be implemented in some
portable/safe way (like via a compiler/os API, with knowledge gleaned from
an autoconf test, a non-buggy runtime test, etc), maybe this wouldn't be
such a bad idea.  For the particular aspect of the problem we're
discussing, once the address space no longer had room for flags it would
always return false and things would just keep working.

Take care,
  Dale
-- 
Dale E. Martin - dale@the-martins.org
http://the-martins.org/~dmartin



Reply to: