From 375acfebca4b84d087bfdfbe9feeca6a01e9dca6 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Tue, 20 Sep 2016 11:03:07 +0100 Subject: [PATCH] Replace casts with floordiv operator in Python xmethods * python/libstdcxx/v6/xmethods.py (DequeWorkerBase.__init__) (DequeWorkerBase.index, VectorWorkerBase.get): Use // for division. From-SVN: r240260 --- libstdc++-v3/ChangeLog | 5 +++++ libstdc++-v3/python/libstdcxx/v6/xmethods.py | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 47af5a081c92..80ca177e7dc4 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2016-09-20 Jonathan Wakely + + * python/libstdcxx/v6/xmethods.py (DequeWorkerBase.__init__) + (DequeWorkerBase.index, VectorWorkerBase.get): Use // for division. + 2016-09-19 Jonathan Wakely PR libstdc++/77645 diff --git a/libstdc++-v3/python/libstdcxx/v6/xmethods.py b/libstdc++-v3/python/libstdcxx/v6/xmethods.py index 17f5937b2c60..4505f0f0669b 100644 --- a/libstdc++-v3/python/libstdcxx/v6/xmethods.py +++ b/libstdc++-v3/python/libstdcxx/v6/xmethods.py @@ -165,7 +165,7 @@ class ArrayMethodsMatcher(gdb.xmethod.XMethodMatcher): class DequeWorkerBase(gdb.xmethod.XMethodWorker): def __init__(self, val_type): self._val_type = val_type - self._bufsize = int(512 / val_type.sizeof) or 1 + self._bufsize = 512 // val_type.sizeof or 1 def size(self, obj): first_node = obj['_M_impl']['_M_start']['_M_node'] @@ -174,10 +174,10 @@ class DequeWorkerBase(gdb.xmethod.XMethodWorker): first = obj['_M_impl']['_M_finish']['_M_first'] return (last_node - first_node) * self._bufsize + (cur - first) - def index(self, obj, index): + def index(self, obj, idx): first_node = obj['_M_impl']['_M_start']['_M_node'] - index_node = first_node + int(index / self._bufsize) - return index_node[0][index % self._bufsize] + index_node = first_node + int(idx) // self._bufsize + return index_node[0][idx % self._bufsize] class DequeEmptyWorker(DequeWorkerBase): def get_arg_types(self): @@ -410,7 +410,7 @@ class VectorWorkerBase(gdb.xmethod.XMethodWorker): if self._val_type.code == gdb.TYPE_CODE_BOOL: start = obj['_M_impl']['_M_start']['_M_p'] bit_size = start.dereference().type.sizeof * 8 - valp = start + int(index / bit_size) + valp = start + index // bit_size offset = index % bit_size return (valp.dereference() & (1 << offset)) > 0 else: