Tighten up dirty_cells()

This commit is contained in:
Kovid Goyal
2016-10-20 14:21:25 +05:30
parent ca30bba165
commit dd767bdf91
2 changed files with 7 additions and 20 deletions
-11
View File
@@ -3,7 +3,6 @@
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
import os
import math
import sys
import termios
import struct
@@ -113,13 +112,3 @@ def timeit(name, do_timing=False):
yield
if do_timing:
print('Time for {}: {}'.format(name, monotonic() - st))
def first_intersecting_bucket(sz, boundary, offset=0):
' Solve the eqn: offset + (n + 1) * sz >= boundary '
return int(math.ceil((boundary - offset) / sz)) - 1
def last_intersecting_bucket(sz, boundary, offset):
' Solve the eqn: offset + n * sz <= boundary '
return int(math.floor((boundary - offset) / sz))