Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

visible_page_numbers is O(n) where n is the number of pages

#253

visible_page_numbers will take a very long time if the number of pages you have is large, say if you are returning web search results that have millions of pages.

Here is the offending code:

  visible   = (1..total_pages).to_a <<< O(n)
  left_gap  = (2 + outer_window)...window_from
  right_gap = (window_to + 1)...(total_pages - outer_window) <<< Again
  visible  -= left_gap.to_a  if left_gap.last - left_gap.first > 1
  visible  -= right_gap.to_a if right_gap.last - right_gap.first > 1

Here is a potential fix that only depend on the size of inner+outer window:

# these are always visible
visible   = (window_from..window_to).to_a

# left window
if window_from > (outer_window + 1) # fully visible
  visible = ((1..(outer_window+1)).to_a + visible)
else # runs into visible pages
  visible = (1...window_from).to_a + visible
end

# right window
if window_to < (total_pages - outer_window) # fully visible
  visible = (visible + (total_pages - outer_window..total_pages).to_a)
else # runs into visible pages
  visible = visible + ((window_to+1)..total_pages).to_a
end

Reported by Lida Tang · November 24th, 2008 @ 11:01 PM

State: resolved
Milestone: none
Assigned to: Mislav Mislav

Activity

  1. Mislav
    Mislav
    • State changed from new to resolved

    Good point. Thanks

    November 25th, 2008 @ 12:42 AM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.