Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
narrow: Single-pass partitioning instead of triple iteration.
Tim Abbottfbc53a6ea483
diff --git a/zerver/lib/narrow.py b/zerver/lib/narrow.pyindex 1a736ab7f20..c06d3ab44de 100644--- a/zerver/lib/narrow.py+++ b/zerver/lib/narrow.py@@ -1355,15 +1355,25 @@ def post_process_limited_query(rows_limited = len(visible_rows) != len(rows)+ before_rows: list[MessageRowT]+ anchor_rows: list[MessageRowT]+ after_rows: list[MessageRowT]if anchored_to_right:num_after = 0- before_rows = visible_rows[:]+ before_rows = list(visible_rows)anchor_rows = []after_rows = []else:- before_rows = [r for r in visible_rows if r[0] < anchor]- anchor_rows = [r for r in visible_rows if r[0] == anchor]- after_rows = [r for r in visible_rows if r[0] > anchor]+ before_rows = []+ anchor_rows = []+ after_rows = []+ for r in visible_rows:+ if r[0] < anchor:+ before_rows.append(r)+ elif r[0] == anchor:+ anchor_rows.append(r)+ else:+ after_rows.append(r)if num_before:before_rows = before_rows[-1 * num_before :]