Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/cdb Revert bloat.



details:   https://anonhg.NetBSD.org/src/rev/f58f64fb0d17
branches:  trunk
changeset: 778040:f58f64fb0d17
user:      joerg <joerg%NetBSD.org@localhost>
date:      Tue Mar 13 21:32:12 2012 +0000

description:
Revert bloat.

diffstat:

 lib/libc/cdb/cdbw.c |  34 ++++++++++++----------------------
 1 files changed, 12 insertions(+), 22 deletions(-)

diffs (102 lines):

diff -r c0c8de8ccfb2 -r f58f64fb0d17 lib/libc/cdb/cdbw.c
--- a/lib/libc/cdb/cdbw.c       Tue Mar 13 21:14:55 2012 +0000
+++ b/lib/libc/cdb/cdbw.c       Tue Mar 13 21:32:12 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cdbw.c,v 1.2 2012/03/13 21:13:31 christos Exp $        */
+/*     $NetBSD: cdbw.c,v 1.3 2012/03/13 21:32:12 joerg Exp $   */
 /*-
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -36,13 +36,12 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: cdbw.c,v 1.2 2012/03/13 21:13:31 christos Exp $");
+__RCSID("$NetBSD: cdbw.c,v 1.3 2012/03/13 21:32:12 joerg Exp $");
 
 #include "namespace.h"
 
 #include <sys/endian.h>
 #include <sys/queue.h>
-#include <assert.h>
 #include <cdbw.h>
 #include <stdlib.h>
 #include <string.h>
@@ -168,8 +167,7 @@
        memcpy(cdbw->data_ptr[cdbw->data_counter], data, datalen);
        cdbw->data_len[cdbw->data_counter] = datalen;
        cdbw->data_size += datalen;
-       _DIAGASSERT(__type_fit(uint32_t, cdbw->data_counter));
-       *idx = (uint32_t)cdbw->data_counter++;
+       *idx = cdbw->data_counter++;
        return 0;
 }
 
@@ -332,9 +330,7 @@
                        return;
        }
 
-       ptrdiff_t td = e - state->edges;
-       _DIAGASSERT(__type_fit(uint32_t, td));
-       state->output_order[--state->output_index] = (uint32_t)td;
+       state->output_order[--state->output_index] = e - state->edges;
 
        vl = &state->verts[e->left];
        vm = &state->verts[e->middle];
@@ -369,7 +365,8 @@
        struct key_hash *key_hash;
        struct vertex *v;
        struct edge *e;
-       uint32_t hashes[3], i;
+       uint32_t hashes[3];
+       size_t i;
 
        e = state->edges;
        for (i = 0; i < cdbw->hash_size; ++i) {
@@ -495,10 +492,8 @@
        memcpy(buf, "NBCDB\n\0", 7);
        buf[7] = 1;
        strncpy((char *)buf + 8, descr, 16);
-       _DIAGASSERT(__type_fit(uint32_t, cdbw->data_size));
-       le32enc(buf + 24, (uint32_t)cdbw->data_size);
-       _DIAGASSERT(__type_fit(uint32_t, cdbw->data_counter));
-       le32enc(buf + 28, (uint32_t)cdbw->data_counter);
+       le32enc(buf + 24, cdbw->data_size);
+       le32enc(buf + 28, cdbw->data_counter);
        le32enc(buf + 32, state->entries);
        le32enc(buf + 36, state->seed);
        cur_pos = 40;
@@ -509,8 +504,7 @@
                le32enc(buf + cur_pos, state->g[i]);
                cur_pos += size;
        }
-       _DIAGASSERT(__type_fit(uint32_t, cdbw->data_counter));
-       size2 = compute_size((uint32_t)cdbw->data_size);
+       size2 = compute_size(cdbw->data_size);
        size = size * state->entries % size2;
        if (size != 0) {
                size = size2 - size;
@@ -522,9 +516,7 @@
                COND_FLUSH_BUFFER(4);
                le32enc(buf + cur_pos, data_size);
                cur_pos += size2;
-               _DIAGASSERT(__type_fit(uint32_t,
-                   data_size + cdbw->data_len[i]));
-               data_size += (uint32_t)cdbw->data_len[i];
+               data_size += cdbw->data_len[i];
        }
        COND_FLUSH_BUFFER(4);
        le32enc(buf + cur_pos, data_size);
@@ -569,10 +561,8 @@
 
        rv = 0;
 
-       _DIAGASSERT(__type_fit(uint32_t, cdbw->key_counter));
-       state.keys = (uint32_t)cdbw->key_counter;
-       _DIAGASSERT(__type_fit(uint32_t, cdbw->key_counter));
-       state.data_entries = (uint32_t)cdbw->data_counter;
+       state.keys = cdbw->key_counter;
+       state.data_entries = cdbw->data_counter;
        state.entries = state.keys + (state.keys + 3) / 4;
        if (state.entries < 10)
                state.entries = 10;



Home | Main Index | Thread Index | Old Index