##// END OF EJS Templates
test-revlog-raw: fix "genbits" implementation...
Jun Wu -
r31763:8a0c4798 default
parent child Browse files
Show More
@@ -166,6 +166,7 b' def genbits(n):'
166
166
167 # Gray Code. See https://en.wikipedia.org/wiki/Gray_code
167 # Gray Code. See https://en.wikipedia.org/wiki/Gray_code
168 gray = lambda x: x ^ (x >> 1)
168 gray = lambda x: x ^ (x >> 1)
169 reversegray = dict((gray(i), i) for i in range(m))
169
170
170 # Generate (n * 2) bit gray code, yield lower n bits as X, and look for
171 # Generate (n * 2) bit gray code, yield lower n bits as X, and look for
171 # the next unused gray code where higher n bits equal to X.
172 # the next unused gray code where higher n bits equal to X.
@@ -177,7 +178,9 b' def genbits(n):'
177 x = 0
178 x = 0
178 yield x
179 yield x
179 for i in range(m * m):
180 for i in range(m * m):
181 x = reversegray[x]
180 y = gray(a[x] + x * m) & (m - 1)
182 y = gray(a[x] + x * m) & (m - 1)
183 assert a[x] < m
181 a[x] += 1
184 a[x] += 1
182 x = y
185 x = y
183 yield x
186 yield x
General Comments 0
You need to be logged in to leave comments. Login now