[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Can we please switch the svndiff integer encoding?

From: Daniel Berlin <dan_at_dberlin.org>
Date: 2002-02-09 21:27:31 CET

Currently, it's almost LEB128 (Little Endian Base 128).
It's not quite, because it uses a different bit for continuation.
LEB128 is used in things such as DWARF2 (a debug info standard), C++
abi's, etc.

It's quite standardized, and quite popular.

Right now we have:

encode_int (char *p, apr_off_t val)
{
  int n;
  apr_off_t v;
  unsigned char cont;

  assert (val >= 0);

  /* Figure out how many bytes we'll need. */
  v = val >> 7;
  n = 1;
  while (v > 0)
    {
      v = v >> 7;
      n++;
    }

  /* Encode the remaining bytes; n is always the number of bytes
     coming after the one we're encoding. */
  while (--n >= 0)
    {
      cont = ((n > 0) ? 0x1 : 0x0) << 7;
      *p++ = ((val >> (n * 7)) & 0x7f) | cont;
    }

  return p;
}

LEB128 would be:

static inline char *
output_uleb128 (p, value)
     char *p;
     valueT value;
{
  do
    {
      unsigned byte = (value & 0x7f);
      value >>= 7;
      if (value != 0)
        /* More bytes to follow. */
        byte |= 0x80;

      *p++ = byte;
    }
  while (value != 0);

  return p;
}

As you can see, the only real difference is the continuation marker.

I think it makes more sense to use something that is widely used, so we
don't have to describe the encoding everywhere.

Just a thought,
Dan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:37:06 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.