Browse Source

EncStdMaps generator

Alexander Shiryaev 12 năm trước cách đây
mục cha
commit
d75440ea56
1 tập tin đã thay đổi với 3 bổ sung16 xóa
  1. 3 16
      BlackBox/Enc/Mod/gen-StdMaps/gen1.py

+ 3 - 16
BlackBox/Enc/Mod/gen-StdMaps/gen1.py

@@ -6,13 +6,6 @@
 
 import sys
 
-def be2le (x):
-	y = 0
-	while x > 0:
-		y = y * 256 + x % 256
-		x = x / 256
-	return y
-
 def nBytes (x):
 	if x == 0:
 		return 1
@@ -76,10 +69,7 @@ def opt0 (r):
 	o = {}
 	for i, x in r:
 		ofs = i - x
-		if o.has_key(ofs):
-			o[ofs].append(x)
-		else:
-			o[ofs] = [ x ]
+		o.setdefault(ofs, []).append(x)
 	return o
 
 # for decoder
@@ -88,10 +78,7 @@ def opt1 (r, nb):
 	for i, x in r:
 		if nBytes(i) == nb:
 			ofs = x - i
-			if o.has_key(ofs):
-				o[ofs].append(i)
-			else:
-				o[ofs] = [ i ]
+			o.setdefault(ofs, []).append(i)
 	return o
 
 def gen (modName, r, head, head0=None):
@@ -113,7 +100,7 @@ def gen (modName, r, head, head0=None):
 		else:
 			errS = ''
 
-	### calc man num of SHORTCHARs per CHAR
+	### calc max num of SHORTCHARs per CHAR
 	maxN = 1
 	for i, x in r:
 		# i: encoding char in big-endian