[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Only check byte order once in proc
commit ad7e2b2a7c0347a15ad5c3712752d3f418ba324e
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Sun Sep 24 11:30:17 2017 -0700
Only check byte order once in proc
---
stem/util/proc.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/stem/util/proc.py b/stem/util/proc.py
index 85f728a2..884ee9ec 100644
--- a/stem/util/proc.py
+++ b/stem/util/proc.py
@@ -79,6 +79,8 @@ try:
except AttributeError:
CLOCK_TICKS = None
+IS_LITTLE_ENDIAN = sys.byteorder == 'little'
+
Stat = stem.util.enum.Enum(
('COMMAND', 'command'), ('CPU_UTIME', 'utime'),
('CPU_STIME', 'stime'), ('START_TIME', 'start time')
@@ -469,10 +471,10 @@ def _decode_proc_address_encoding(addr, is_ipv6):
port = int(port, 16) # the port is represented as a two-byte hexadecimal number
if not is_ipv6:
- ip_encoded = base64.b16decode(ip)[::-1] if sys.byteorder == 'little' else base64.b16decode(ip)
+ ip_encoded = base64.b16decode(ip)[::-1] if IS_LITTLE_ENDIAN else base64.b16decode(ip)
ip = socket.inet_ntop(socket.AF_INET, ip_encoded)
else:
- if sys.byteorder == 'little':
+ if IS_LITTLE_ENDIAN:
# Group into eight characters, then invert in pairs...
#
# https://trac.torproject.org/projects/tor/ticket/18079#comment:24
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits