]> git.lizzy.rs Git - rust.git/commitdiff
add some debugging logs
authorNiko Matsakis <niko@alum.mit.edu>
Wed, 7 Dec 2011 05:33:47 +0000 (21:33 -0800)
committerNiko Matsakis <niko@alum.mit.edu>
Thu, 8 Dec 2011 01:05:58 +0000 (17:05 -0800)
src/libstd/map.rs

index bacbca37a473fe6e6db8bda8faa7535779ffe7a8..1f34a682449723f4f9645eb0daca0465597c8128 100644 (file)
@@ -133,16 +133,24 @@ mod chained {
     fn search_rem<copy K, copy V>(tbl: t<K,V>,
                                   k: K,
                                   h: uint,
+                                  idx: uint,
                                   e_root: @entry<K,V>) -> search_result<K,V> {
         let e0 = e_root;
+        let comp = 1u;   // for logging
         while true {
             alt e0.next {
               absent. {
+                log("search_tbl", "absent", "comparisons", comp,
+                    "hash", h, "idx", idx);
+
                 ret not_found;
               }
               present(e1) {
+                comp += 1u;
                 let e1_key = e1.key; // Satisfy alias checker.
                 if e1.hash == h && tbl.eqer(e1_key, k) {
+                    log("search_tbl", "present", "comparisons", comp,
+                        "hash", h, "idx", idx);
                     ret found_after(e0, e1);
                 } else {
                     e0 = e1;
@@ -158,14 +166,18 @@ fn search_tbl<copy K, copy V>(
         let idx = h % vec::len(tbl.chains);
         alt tbl.chains[idx] {
           absent. {
+            log("search_tbl", "absent", "comparisons", 0u,
+                "hash", h, "idx", idx);
             ret not_found;
           }
           present(e) {
             let e_key = e.key; // Satisfy alias checker.
             if e.hash == h && tbl.eqer(e_key, k) {
+                log("search_tbl", "present", "comparisons", 1u,
+                    "hash", h, "idx", idx);
                 ret found_first(idx, e);
             } else {
-                ret search_rem(tbl, k, h, e);
+                ret search_rem(tbl, k, h, idx, e);
             }
           }
         }