Skip to content

Commit 9375ceb

Browse files
committed
demo impact of avoiding the first letter
1 parent 63cbe2c commit 9375ceb

File tree

6 files changed

+397
-400
lines changed

6 files changed

+397
-400
lines changed

packages/cursorless-engine/src/test/fixtures/hat-stats/intern.go.golden

Lines changed: 58 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
1-
* * * * * *
1+
* * * * * *
22
// Package intern interns strings.
33
[] [-----] [----] [-----] [-----]|
44

5-
b b b
6-
* * * * * * *
5+
b b
6+
* * * * * * *
77
// Interning is best effort only.
88
[] [-------] [] [--] [----] [--]|
99

10-
g b
11-
* * * * * * *
10+
g
11+
* * * * * * *
1212
// Interned strings may be removed automatically
1313
[] [------] [-----] [-] [] [-----] [-----------]
1414

15-
r b g
16-
* * * * * * *
15+
r b b g
16+
* * * * * * *
1717
// at any time without notification.
1818
[] [] [-] [--] [-----] [----------]|
1919

20-
p b g b
21-
* * * * * * *
20+
p b b b b b
21+
* * * * * * *
2222
// All functions may be called concurrently
2323
[] [-] [-------] [-] [] [----] [----------]
2424

25-
y b b b b r
26-
* * * * * * *
25+
y b g b gr
26+
* * * * * **
2727
// with themselves and each other.
2828
[] [--] [--------] [-] [--] [---]|
2929

30-
b
31-
* *
30+
g
31+
* *
3232
package intern
3333
[-----] [----]
3434

35-
b b b
36-
* * * *
35+
g b
36+
* * * *
3737
import "sync"
3838
[----] |[--]|
3939

40-
g g g pb r yg
41-
* * * ** * * ** *
40+
b g r p b p y g
41+
* * * * * * * * * *
4242
var pool sync.Pool = sync.Pool{
4343
[-] [--] [--]|[--] | [--]|[--]|
4444

45-
b b g b g
46-
** * ** * ** *
45+
b b g b g
46+
** * ** * ** *
4747
␉New: func() interface{} {
4848
[-]| [--]|| [-------]|| |
4949

50-
b b b r b p b
51-
* * * ** *** *
50+
g b b b b r b
51+
* * * ** ** * *
5252
␉␉return make(map[string]string)
5353
[----] [--]|[-]|[----]|[----]|
5454

@@ -62,37 +62,37 @@ g
6262
}
6363
|
6464

65-
1 y g 1b g1
66-
* * * ** **
65+
1 p r bb r1
66+
* * * ** **
6767
// String returns s, interned.
6868
[] [----] [-----] || [------]|
6969

70-
g gg2 b g r
71-
* *** * * x *
70+
g ggg y g 1 r
71+
* *** * * * *
7272
func String(s string) string {
7373
[--] [----]|| [----]| [----] |
7474

75-
g bb g 2 g rr p g b b p
76-
* ** * * * **x* * *v *w *
75+
b bb r 2 g rr p g b r b 2 p
76+
* ** * * * **x* * * * * * *
7777
␉m := pool.Get().(map[string]string)
7878
| || [--]|[-]||||[-]|[----]|[----]|
7979

80-
gg g gg rg g
81-
** * ** **o*
80+
rg g gg ggrg
81+
** * ** ****
8282
␉c, ok := m[s]
8383
|| [] || ||||
8484

85-
r r p
86-
* * *
85+
b r p
86+
* * *
8787
␉if ok {
8888
[] [] |
8989

90-
r r ypy
90+
r p yry
9191
*v * ***
9292
␉␉pool.Put(m)
9393
[--]|[-]|||
9494

95-
r r
95+
r p
9696
* *
9797
␉␉return c
9898
[----] |
@@ -102,18 +102,18 @@ func String(s string) string {
102102
␉}
103103
|
104104

105-
yr r r
106-
**#* * ^
105+
prpr r y
106+
**** * *
107107
␉m[s] = s
108108
|||| | |
109109

110-
p p 111
110+
p y 1y1
111111
* w * ***
112112
␉pool.Put(m)
113113
[--]|[-]|||
114114

115-
b
116-
* 0
115+
p 1
116+
* *
117117
␉return s
118118
[----] |
119119

@@ -122,37 +122,37 @@ p
122122
}
123123
|
124124

125-
2 r g p r g r rr p
126-
* * * * * * * ** * o
125+
2 y 1 b g y r rr y
126+
* * * * * * * ** * o
127127
// Bytes returns b converted to a string, interned.
128128
[] [---] [-----] | [-------] [] | [----]| [------]|
129129

130-
p g 2y pp r 2 p y
131-
* * ** ** * * * *
130+
2 1 2g pp 2 2 p y
131+
* * ** ** * * * *
132132
func Bytes(b []byte) string {
133133
[--] [---]|| ||[--]| [----] |
134134

135-
2 rp p y p y y
136-
* ** *# * xx^v * *> *~ v
135+
1 rp p 1 p y p y
136+
* ** *# * xx^v * * * * x v
137137
␉m := pool.Get().(map[string]string)
138138
| || [--]|[-]||||[-]|[----]|[----]|
139139

140-
pp r py 1 1 1
141-
** * ** x*+ w*w*
140+
yp p py 21 r 1
141+
** * ** ** v w*w*
142142
␉c, ok := m[string(b)]
143143
|| [] || ||[----]||||
144144

145-
y y 1
146-
* * *
145+
g y 1
146+
* * *
147147
␉if ok {
148148
[] [] |
149149

150-
y y
151-
*0 * ovo
150+
y
151+
*0 x oxo
152152
␉␉pool.Put(m)
153153
[--]|[-]|||
154154

155-
1 y
155+
2 1
156156
* *
157157
␉␉return c
158158
[----] |
@@ -162,23 +162,22 @@ func Bytes(b []byte) string {
162162
␉}
163163
|
164164

165-
b y1 y 2
166-
x ** *#*#
165+
2 y1 y p
166+
* ** *#*#
167167
␉s := string(b)
168168
| || [----]|||
169169

170-
2b2 2 b
171-
w*v* * w
170+
2 2 2
171+
v*x* * v
172172
␉m[s] = s
173173
|||| | |
174174

175-
1 1
176-
* > * ^o^
175+
1
176+
* > v ^w^
177177
␉pool.Put(m)
178178
[--]|[-]|||
179179

180-
2 b
181-
* o
180+
x w
182181
␉return s
183182
[----] |
184183

packages/cursorless-engine/src/test/fixtures/hat-stats/intern.go.stats

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ nPenalty0:
1414
spark: 0 █ 25 50 75 100
1515

1616
nPenalty1:
17-
mean: 84%
18-
std: 1%
19-
min: 83%
17+
mean: 85%
18+
std: 0%
19+
min: 85%
2020
max: 85%
21-
spark: 0 25 50 75 █ 100
21+
spark: 0 25 50 75 █ 100
2222

2323
nPenalty2:
24-
mean: 1%
25-
std: 1%
24+
mean: 0%
25+
std: 0%
2626
min: 0%
27-
max: 2%
27+
max: 0%
2828
spark: 0 █ 25 50 75 100
2929

0 commit comments

Comments
 (0)