RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  [email protected]
  Module: rpm                              Date:   27-Jun-2009 06:06:24
  Branch: HEAD                             Handle: 2009062704062400

  Modified files:
    rpm/rpmio               crc.c

  Log:
    - generate crc lookup lazily instead of explicitly.

  Summary:
    Revision    Changes     Path
    2.2         +10 -4      rpm/rpmio/crc.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/rpmio/crc.c
  ============================================================================
  $ cvs diff -u -r2.1 -r2.2 crc.c
  --- rpm/rpmio/crc.c   14 Oct 2008 19:24:10 -0000      2.1
  +++ rpm/rpmio/crc.c   27 Jun 2009 04:06:24 -0000      2.2
  @@ -12,10 +12,11 @@
       static rpmuint32_t polynomial = 0xedb88320;    /* reflected 0x04c11db7 */
       static rpmuint32_t xorout = 0xffffffff;
       static rpmuint32_t table[256];
  +    static int oneshot = 0;
   
       crc ^= xorout;
   
  -    if (data == NULL) {
  +    if (!oneshot) {
        /* generate the table of CRC remainders for all possible bytes */
        rpmuint32_t c;
        rpmuint32_t i, j;
  @@ -29,7 +30,9 @@
            }
            table[i] = c;
        }
  -    } else
  +     oneshot = 1;
  +    }
  +    if (data != NULL)
       while (size) {
        crc = table[(crc ^ *data) & 0xff] ^ (crc >> 8);
        size--;
  @@ -140,10 +143,11 @@
        0xc96c5795d7870f42ULL;  /* reflected 0x42f0e1eba9ea3693ULL */
       static rpmuint64_t xorout = 0xffffffffffffffffULL;
       static rpmuint64_t table[256];
  +    static int oneshot = 0;
   
       crc ^= xorout;
   
  -    if (data == NULL) {
  +    if (!oneshot) {
        /* generate the table of CRC remainders for all possible bytes */
        rpmuint64_t c;
        rpmuint32_t i, j;
  @@ -157,7 +161,9 @@
            }
            table[i] = c;
        }
  -    } else
  +     oneshot = 1;
  +    }
  +    if (data != NULL)
       while (size) {
        crc = table[(crc ^ *data) & 0xff] ^ (crc >> 8);
        size--;
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                [email protected]

Reply via email to