Skip to content

Commit a6e24cb

Browse files
authored
Use struct instead of int bytes conversion (#1474)
1 parent db85b58 commit a6e24cb

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

bugbug/test_scheduling.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import os
88
import pickle
99
import shelve
10-
import sys
10+
import struct
1111

1212
from bugbug import db, repository
1313
from bugbug.utils import ExpQueue, LMDBDict
@@ -116,7 +116,7 @@ def get_touched_together(f1, f2):
116116
if key not in touched_together:
117117
return 0
118118

119-
return int.from_bytes(touched_together[key], sys.byteorder)
119+
return struct.unpack("I", touched_together[key])[0]
120120

121121

122122
def set_touched_together(f1, f2):
@@ -125,11 +125,11 @@ def set_touched_together(f1, f2):
125125
key = get_touched_together_key(f1, f2)
126126

127127
if key not in touched_together:
128-
touched_together[key] = (1).to_bytes(4, sys.byteorder)
128+
touched_together[key] = struct.pack("I", 1)
129129
else:
130-
touched_together[key] = (
131-
int.from_bytes(touched_together[key], sys.byteorder) + 1
132-
).to_bytes(4, sys.byteorder)
130+
touched_together[key] = struct.pack(
131+
"I", struct.unpack("I", touched_together[key])[0] + 1
132+
)
133133

134134

135135
def update_touched_together():

0 commit comments

Comments
 (0)