Skip to content

Commit

Permalink
Use struct instead of int bytes conversion (#1474)
Browse files Browse the repository at this point in the history
  • Loading branch information
yabirgb authored Apr 9, 2020
1 parent db85b58 commit a6e24cb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions bugbug/test_scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os
import pickle
import shelve
import sys
import struct

from bugbug import db, repository
from bugbug.utils import ExpQueue, LMDBDict
Expand Down Expand Up @@ -116,7 +116,7 @@ def get_touched_together(f1, f2):
if key not in touched_together:
return 0

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


def set_touched_together(f1, f2):
Expand All @@ -125,11 +125,11 @@ def set_touched_together(f1, f2):
key = get_touched_together_key(f1, f2)

if key not in touched_together:
touched_together[key] = (1).to_bytes(4, sys.byteorder)
touched_together[key] = struct.pack("I", 1)
else:
touched_together[key] = (
int.from_bytes(touched_together[key], sys.byteorder) + 1
).to_bytes(4, sys.byteorder)
touched_together[key] = struct.pack(
"I", struct.unpack("I", touched_together[key])[0] + 1
)


def update_touched_together():
Expand Down

0 comments on commit a6e24cb

Please sign in to comment.