From: Niels Möller Date: Mon, 30 Sep 2002 19:39:23 +0000 (+0200) Subject: (base64_encode): Broke out some common code from the switch.. X-Git-Tag: nettle_1.6_release_20021003~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cff9e510f3979df48e30de6ad6fc315ae037e9fa;p=thirdparty%2Fnettle.git (base64_encode): Broke out some common code from the switch.. Rev: src/nettle/base64.c:1.4 --- diff --git a/base64.c b/base64.c index 7124060e..566cd30b 100644 --- a/base64.c +++ b/base64.c @@ -71,27 +71,24 @@ base64_encode(uint8_t *dst, if (left_over) { + in -= left_over; + *--out = '='; switch(left_over) { case 1: - in--; - *--out = '='; *--out = '='; *--out = ENCODE(in[0] << 4); - *--out = ENCODE(in[0] >> 2); break; case 2: - in-= 2; - *--out = '='; *--out = ENCODE( in[1] << 2); *--out = ENCODE((in[0] << 4) | (in[1] >> 4)); - *--out = ENCODE( in[0] >> 2); break; default: abort(); } + *--out = ENCODE(in[0] >> 2); } while (in > src)