File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 8282"""
8383
8484import os .path
85- import sys
8685from bisect import (
8786 insort ,
8887 insort_right ,
124123 BIN_OFFSETS_MAX .insert (0 , (BIN_OFFSETS_MAX [0 ] << BIN_NEXT_SHIFT ))
125124# The maximum size for the top bin is actually bigger than the signed integers
126125# we use to store positions in the file, so we'll change it to prevent confusion
127- BIN_OFFSETS_MAX [0 ] = sys . maxsize
126+ BIN_OFFSETS_MAX [0 ] = 2 ** 63
128127
129128# Constants for the minimum and maximum size of the overall interval
130129MIN = 0
@@ -137,12 +136,14 @@ def offsets_for_max_size(max_size):
137136 """
138137 Return the subset of offsets needed to contain intervals over (0,max_size)
139138 """
140- for i , max in enumerate (reversed (BIN_OFFSETS_MAX )):
141- if max_size < max :
139+ offset_index = None
140+ for i , off_max in enumerate (reversed (BIN_OFFSETS_MAX )):
141+ if max_size <= off_max :
142+ offset_index = i
142143 break
143- else :
144+ if offset_index is None :
144145 raise Exception ("%d is larger than the maximum possible size (%d)" % (max_size , BIN_OFFSETS_MAX [0 ]))
145- return BIN_OFFSETS [(len (BIN_OFFSETS ) - i - 1 ) :]
146+ return BIN_OFFSETS [(len (BIN_OFFSETS ) - offset_index - 1 ):]
146147
147148
148149def bin_for_range (start , end , offsets = None ):
You can’t perform that action at this time.
0 commit comments