Wed, 26 Jan 2022 10:11:01 -0800 encoding: fix trim() to be O(n) instead of O(n^2)
Martin von Zweigbergk <martinvonz@google.com> [Wed, 26 Jan 2022 10:11:01 -0800] rev 48692
encoding: fix trim() to be O(n) instead of O(n^2) `encoding.trim()` iterated over the possible lengths smaller than the input and created a slice for each. It then calculated the column width of the result, which is of course O(n), so the overall algorithm was O(n). This patch rewrites it to iterate over the unicode characters, keeping track of the length so far. Also, the old algorithm started from the end of the string, which made it much worse when the input is large and the limit is small (such as the typical 72 we pass to it). You can time it by running something like this: ``` time python3 -c 'from mercurial.utils import stringutil; print(stringutil.ellipsis(b"0123456789" * 1000, 5))' ``` That drops from 4.05 s to 83 ms with this patch (and most of that is of course startup time). Differential Revision: https://phab.mercurial-scm.org/D12089
Tue, 11 Jan 2022 21:40:08 +0100 share-safe: enable by default (BC)
Pierre-Yves David <pierre-yves.david@octobus.net> [Tue, 11 Jan 2022 21:40:08 +0100] rev 48691
share-safe: enable by default (BC) The feature have been around for a year (4 version) and is quite important. Lets make it enabled by default. Differential Revision: https://phab.mercurial-scm.org/D11997
(0) -30000 -10000 -3000 -1000 -300 -100 -30 -10 -2 +2 +10 +30 +100 +300 +1000 +3000 tip