diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-01-31 00:42:29 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-01-31 00:42:29 +0100 |
commit | 631c16855a05f0699149502bba93a3ad8f88608e (patch) | |
tree | 6eeb9b56710ae8159d95c234fc98315fb84dbde2 | |
parent | b7dfbbcdaaae5267259e2272b1cdfde6daad44a0 (diff) | |
download | busybox-w32-631c16855a05f0699149502bba93a3ad8f88608e.tar.gz busybox-w32-631c16855a05f0699149502bba93a3ad8f88608e.tar.bz2 busybox-w32-631c16855a05f0699149502bba93a3ad8f88608e.zip |
gzip: optionally faster put_32bit()
function old new delta
put_32bit 22 55 +33
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | archival/gzip.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/archival/gzip.c b/archival/gzip.c index 08633d667..5812f4b27 100644 --- a/archival/gzip.c +++ b/archival/gzip.c | |||
@@ -454,7 +454,7 @@ static void put_16bit(ush w) | |||
454 | if (outcnt < OUTBUFSIZ-2) { | 454 | if (outcnt < OUTBUFSIZ-2) { |
455 | /* Common case */ | 455 | /* Common case */ |
456 | ush *dst16 = (void*) dst; | 456 | ush *dst16 = (void*) dst; |
457 | *dst16 = w; /* unalinged LSB 16-bit store */ | 457 | *dst16 = w; /* unaligned LSB 16-bit store */ |
458 | G1.outcnt = outcnt + 2; | 458 | G1.outcnt = outcnt + 2; |
459 | return; | 459 | return; |
460 | } | 460 | } |
@@ -480,6 +480,18 @@ static void put_16bit(ush w) | |||
480 | 480 | ||
481 | static void put_32bit(ulg n) | 481 | static void put_32bit(ulg n) |
482 | { | 482 | { |
483 | #if CONFIG_GZIP_FAST > 0 \ | ||
484 | && BB_UNALIGNED_MEMACCESS_OK && BB_LITTLE_ENDIAN | ||
485 | unsigned outcnt = G1.outcnt; | ||
486 | if (outcnt < OUTBUFSIZ-4) { | ||
487 | /* Common case */ | ||
488 | uch *dst = &G1.outbuf[outcnt]; | ||
489 | ulg *dst32 = (void*) dst; | ||
490 | *dst32 = n; /* unaligned LSB 32-bit store */ | ||
491 | G1.outcnt = outcnt + 4; | ||
492 | return; | ||
493 | } | ||
494 | #endif | ||
483 | put_16bit(n); | 495 | put_16bit(n); |
484 | put_16bit(n >> 16); | 496 | put_16bit(n >> 16); |
485 | } | 497 | } |
@@ -544,7 +556,7 @@ static void send_bits(unsigned value, unsigned length) | |||
544 | */ | 556 | */ |
545 | value >>= (BUF_SIZE - G1.bi_valid); | 557 | value >>= (BUF_SIZE - G1.bi_valid); |
546 | if (BUF_SIZE == 32) { | 558 | if (BUF_SIZE == 32) { |
547 | put_32bit(new_buf); /* maybe unroll to 2*put_16bit()? */ | 559 | put_32bit(new_buf); |
548 | } else { /* 16 */ | 560 | } else { /* 16 */ |
549 | put_16bit(new_buf); | 561 | put_16bit(new_buf); |
550 | } | 562 | } |