]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Let all platforms defining UNALIGNED_OK use the optimized put_short
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Thu, 23 Feb 2017 08:04:48 +0000 (09:04 +0100)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Thu, 23 Feb 2017 08:04:48 +0000 (09:04 +0100)
implementation. Also change from pre-increment to post-increment to
prevent a double-store on non-x86 platforms.

deflate.h

index acd342d102d392bc09f9585a6c56411a212e46f3..37e5596801f8c75651d0d1079d8bae5040acbc64 100644 (file)
--- a/deflate.h
+++ b/deflate.h
@@ -307,7 +307,7 @@ typedef enum {
  * Output a short LSB first on the stream.
  * IN assertion: there is enough room in pendingBuf.
  */
-#if defined(__x86_64) || defined(__i386_)
+#ifdef UNALIGNED_OK
 /* Compared to the else-clause's implementation, there are few advantages:
  *  - s->pending is loaded only once (else-clause's implementation needs to
  *    load s->pending twice due to the alias between s->pending and
@@ -318,8 +318,8 @@ typedef enum {
  *    cost of penalty of potentially unaligned access. 
  */
 #define put_short(s, w) { \
+    *(uint16_t*)(&s->pending_buf[s->pending]) = (w) ; \
     s->pending += 2; \
-    *(uint16_t*)(&s->pending_buf[s->pending - 2]) = (w) ; \
 }
 #else
 #define put_short(s, w) { \