Mercurial > hg
annotate tests/test-censor2.t @ 50400:95acba2c29f6
encoding: avoid quadratic time complexity when json-encoding non-UTF8 strings
Apparently the code uses "+=" with a bytes object, which is linear-time, so the
whole encoding is quadratic-time. This patch makes us use a bytearray object,
instead, which has a(n amortized-)constant-time append operation.
The encoding is still not particularly fast, but at least a 10MB file
takes tens of seconds, not many hours to encode.
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Mon, 06 Mar 2023 11:27:57 +0000 |
parents | 77b5a190571c |
children | 195ab99cf791 |
rev | line source |
---|---|
49165
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
1 $ cat >> $HGRCPATH <<EOF |
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
2 > [censor] |
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
3 > policy=ignore |
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
4 > EOF |
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
5 |
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
6 $ mkdir r |
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
7 $ cd r |
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
8 $ hg init |
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
9 $ echo secret > target |
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
10 $ hg commit -Am "secret" |
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
11 adding target |
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
12 $ touch bystander |
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
13 $ hg commit -Am "innocent" |
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
14 adding bystander |
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
15 $ echo erased-secret > target |
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
16 $ hg commit -m "erased secret" |
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
17 $ hg censor target --config extensions.censor= -r ".^^" |
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
18 $ hg update ".^" |
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
19 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
20 $ cat target |
72936be2a21b
censor: demonstrate a bug
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
diff
changeset
|
21 $ hg update tip |
49166
77b5a190571c
censor: fix [hg update] away from a revision with censored files
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49165
diff
changeset
|
22 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |