[PATCH] D46485: Add python tool to dump and construct header maps

Jan Korous via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 16 13:26:56 PDT 2018


jkorous added a comment.

LGTM but my review was fairly superficial.



================
Comment at: utils/hmaptool/hmaptool:55
+            # The number of buckets must be a power of two.
+            if num_buckets == 0 or (num_buckets & num_buckets - 1) != 0:
+                raise SystemExit("error: %s: invalid number of buckets" % (
----------------
bruno wrote:
> jkorous wrote:
> > Wouldn't it be simpler to use modulo 2?
> > 
> > ```
> > if num_buckets % 2 == 0
> > ```
> We want it to be a power of two, not just a multiple.
Of course! Sorry, my mistake.


================
Comment at: utils/hmaptool/hmaptool:155
+        raise ArgumentError
+    return 1 if value == 0 else 2**(value - 1).bit_length()
+
----------------
Thanks for teaching me bit_length()!


https://reviews.llvm.org/D46485





More information about the cfe-commits mailing list