From: linux@horizon.com
To: git@vger.kernel.org, torvalds@osdl.org
Subject: Re: kernel.org and GIT tree rebuilding
Date: 3 Jul 2005 02:51:12 -0000 [thread overview]
Message-ID: <20050703025112.18758.qmail@science.horizon.com> (raw)
> unsigned long size;
> unsigned char c;
>
> c = *pack++;
> size = c & 15;
> type = (c >> 4) & 7;
> while (c & 0x80) {
> c = *pack++;
> size = (size << 7) + (c & 0x7f);
> }
>
> or something. That's even denser.
If you're going for density, you missed something. Try:
c = *pack++;
size = c & 15;
type = (c >> 4) & 7;
while (c & 0x80) {
c = *pack++;
size = (size << 7) + (c & 0x7f) + 16;
}
Encoding is most easily done in little-endian order, such as:
static unsigned
encode(unsigned char *p, unsigned long x)
{
unsigned char *q = p;
unsigned char buf[5];
unsigned char *b = buf;
while (x > 15) {
assert(b < buf+5);
x -= 16;
*b++ = x & 0x7f;
x >>= 7;
}
*b = x;
while (b != buf)
*q++ = *b-- | 0x80;
*q++ = *b;
return (unsigned)(q - p);
}
(You'll probably want to rewrite the above, but it's abandoned to the
public domain in any case. Go nuts.)
next reply other threads:[~2005-07-03 2:51 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-03 2:51 linux [this message]
-- strict thread matches above, loose matches on Subject: below --
2005-06-25 4:20 kernel.org and GIT tree rebuilding David S. Miller
2005-06-25 4:40 ` Jeff Garzik
2005-06-25 5:23 ` Linus Torvalds
2005-06-25 5:48 ` Jeff Garzik
2005-06-25 6:16 ` Linus Torvalds
2005-06-26 16:41 ` Linus Torvalds
2005-06-26 18:39 ` Junio C Hamano
2005-06-26 19:19 ` Linus Torvalds
2005-06-26 19:45 ` Junio C Hamano
2005-06-26 20:52 ` Chris Mason
2005-06-26 21:03 ` Chris Mason
2005-06-26 21:40 ` Linus Torvalds
2005-06-26 22:34 ` Linus Torvalds
2005-06-28 18:06 ` Nicolas Pitre
2005-06-28 19:28 ` Linus Torvalds
2005-06-28 21:08 ` Nicolas Pitre
2005-06-28 21:27 ` Linus Torvalds
2005-06-29 3:55 ` Nicolas Pitre
2005-06-29 5:16 ` Nicolas Pitre
2005-06-29 5:43 ` Linus Torvalds
2005-06-29 5:54 ` Linus Torvalds
2005-06-25 5:04 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050703025112.18758.qmail@science.horizon.com \
--to=linux@horizon.com \
--cc=git@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).