Skip to content

Commit

Permalink
use integer ops instead of float with ceil / floor
Browse files Browse the repository at this point in the history
  • Loading branch information
renxida committed Dec 4, 2024
1 parent 1aed0ee commit 7274064
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,12 @@ def has_common_prefix(tokens1, tokens2):

tokens_per_page = self.cache.tokens_per_page

number_of_pages_to_publish = len(tokens) / tokens_per_page
if publish_incomplete_page:
number_of_pages_to_publish = math.ceil(number_of_pages_to_publish)
number_of_pages_to_publish = -(
len(tokens) // -tokens_per_page
) # ceil division
else:
number_of_pages_to_publish = math.floor(number_of_pages_to_publish)
number_of_pages_to_publish = len(tokens) // tokens_per_page

# Create token blocks for unpublished pages
start_token_index = self.number_of_published_pages * tokens_per_page
Expand Down

0 comments on commit 7274064

Please sign in to comment.