[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [nyx/master] Ensure division order of operations



commit b1443805250655807436d23f4fb154b2f622510e
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Wed Nov 16 09:35:14 2016 -0800

    Ensure division order of operations
    
    Order of operations don't matter when just multiplying and dividing... *unless*
    you're doing integer division. I don't know offhand what python's binding order
    is nor do I want to rely on it, so forcing multiplication to go first.
---
 nyx/curses.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/nyx/curses.py b/nyx/curses.py
index 78eb14e..b733449 100644
--- a/nyx/curses.py
+++ b/nyx/curses.py
@@ -886,8 +886,8 @@ class _Subwindow(object):
 
     scrollbar_height = self.height - top - 1  # -1 is for the bottom border
     bottom_index = top_index + scrollbar_height + 1
-    slider_top = scrollbar_height * top_index // size
-    slider_size = scrollbar_height * (bottom_index - top_index) // size
+    slider_top = (scrollbar_height * top_index) // size
+    slider_size = (scrollbar_height * (bottom_index - top_index)) // size
     max_slider_top = scrollbar_height - slider_size - 1
 
     # ensures slider isn't at top or bottom unless really at those extreme bounds



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits