fork of https://github.com/sourcegraph/zoekt
1# vendored std regexp/syntax
2
3This package contains a vendored copy of std regexp/syntax. However, it only
4contains the code for converting syntax.Regexp into a String. It is the
5version of the code at a recent go commit, but with a commit which introduces
6a significant performance regression reverted.
7
8At the time of writing regexp.String on go1.22 is taking 40% of CPU at
9Sourcegraph. This should return to ~0% with this vendored code.
10
11https://github.com/sourcegraph/sourcegraph/issues/61462
12
13## Vendored commit
14
15```
16commit 2e1003e2f7e42efc5771812b9ee6ed264803796c
17Author: Daniel Martí <mvdan@mvdan.cc>
18Date: Tue Mar 26 22:59:41 2024 +0200
19
20 cmd/go: replace reflect.DeepEqual with slices.Equal and maps.Equal
21
22 All of these maps and slices are made up of comparable types,
23 so we can avoid the overhead of reflection entirely.
24
25 Change-Id: If77dbe648a336ba729c171e84c9ff3f7e160297d
26 Reviewed-on: https://go-review.googlesource.com/c/go/+/574597
27 Reviewed-by: Than McIntosh <thanm@google.com>
28 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
29 Reviewed-by: Ian Lance Taylor <iant@google.com>
30```
31
32## Reverted commit
33
34```
35commit 98c9f271d67b501ecf2ce995539abd2cdc81d505
36Author: Russ Cox <rsc@golang.org>
37Date: Wed Jun 28 17:45:26 2023 -0400
38
39 regexp/syntax: use more compact Regexp.String output
40
41 Compact the Regexp.String output. It was only ever intended for debugging,
42 but there are at least some uses in the wild where regexps are built up
43 using regexp/syntax and then formatted using the String method.
44 Compact the output to help that use case. Specifically:
45
46 - Compact 2-element character class ranges: [a-b] -> [ab].
47 - Aggregate flags: (?i:A)(?i:B)*(?i:C)|(?i:D)?(?i:E) -> (?i:AB*C|D?E).
48
49 Fixes #57950.
50
51 Change-Id: I1161d0e3aa6c3ae5a302677032bb7cd55caae5fb
52 Reviewed-on: https://go-review.googlesource.com/c/go/+/507015
53 TryBot-Result: Gopher Robot <gobot@golang.org>
54 Reviewed-by: Than McIntosh <thanm@google.com>
55 Run-TryBot: Russ Cox <rsc@golang.org>
56 Reviewed-by: Rob Pike <r@golang.org>
57 Auto-Submit: Russ Cox <rsc@golang.org>
58```