Source-Changes-HG archive

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

[src/trunk]: src/common/lib/libc/gen Don't bother testing 0 length keys since...



details:   https://anonhg.NetBSD.org/src/rev/93038fc0c616
branches:  trunk
changeset: 780147:93038fc0c616
user:      matt <matt%NetBSD.org@localhost>
date:      Fri Jul 13 01:15:27 2012 +0000

description:
Don't bother testing 0 length keys since they can only have one possible value.

diffstat:

 common/lib/libc/gen/ptree.c |  11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diffs (46 lines):

diff -r 5e3a85aa0cf3 -r 93038fc0c616 common/lib/libc/gen/ptree.c
--- a/common/lib/libc/gen/ptree.c       Thu Jul 12 23:07:06 2012 +0000
+++ b/common/lib/libc/gen/ptree.c       Fri Jul 13 01:15:27 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ptree.c,v 1.6 2012/07/11 00:19:28 rmind Exp $  */
+/*     $NetBSD: ptree.c,v 1.7 2012/07/13 01:15:27 matt Exp $   */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
 #include <sys/types.h>
 #include <sys/systm.h>
 #include <lib/libkern/libkern.h>
-__KERNEL_RCSID(0, "$NetBSD: ptree.c,v 1.6 2012/07/11 00:19:28 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ptree.c,v 1.7 2012/07/13 01:15:27 matt Exp $");
 #else
 #include <stddef.h>
 #include <stdint.h>
@@ -53,7 +53,7 @@
 #else
 #define        KASSERT(e)      do { } while (/*CONSTCOND*/ 0)
 #endif
-__RCSID("$NetBSD: ptree.c,v 1.6 2012/07/11 00:19:28 rmind Exp $");
+__RCSID("$NetBSD: ptree.c,v 1.7 2012/07/13 01:15:27 matt Exp $");
 #endif /* _KERNEL || _STANDALONE */
 
 #ifdef _LIBC
@@ -134,7 +134,7 @@
 {
        const pt_bitlen_t bitlen = PTN_BRANCH_BITLEN(ptn);
        if (bitlen == 0)
-               return PT_SLOT_ROOT;
+               return PT_SLOT_ROOT;    /* mask or root, doesn't matter */
        return (*pt->pt_ops->ptto_testnode)(NODETOKEY(pt, target),
            PTN_BRANCH_BITOFF(ptn), bitlen, pt->pt_context);
 }
@@ -150,6 +150,9 @@
 static inline pt_slot_t
 ptree_testkey(const pt_tree_t *pt, const void *key, const pt_node_t *ptn)
 {
+       const pt_bitlen_t bitlen = PTN_BRANCH_BITLEN(ptn);
+       if (bitlen == 0)
+               return PT_SLOT_ROOT;    /* mask or root, doesn't matter */
        return (*pt->pt_ops->ptto_testkey)(key, PTN_BRANCH_BITOFF(ptn),
            PTN_BRANCH_BITLEN(ptn), pt->pt_context);
 }



Home | Main Index | Thread Index | Old Index