Skip to content

Commit 64a3a04

Browse files
committed
reduce unused Regexp compile
1 parent b12279c commit 64a3a04

File tree

2 files changed

+0
-61
lines changed

2 files changed

+0
-61
lines changed

go/vimlfunc.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,10 @@ var patVim2Go = map[string]string{
6666
}
6767

6868
var patVim2GoRegh = make(map[string]*regexp.Regexp)
69-
var patVim2GoRegq = make(map[string]*regexp.Regexp)
7069

7170
func init() {
7271
for k, v := range patVim2Go {
7372
patVim2GoRegh[k] = regexp.MustCompile(v)
74-
patVim2GoRegq[k] = regexp.MustCompile("(?i)" + v)
7573
}
7674
}
7775

@@ -84,12 +82,6 @@ func viml_empty(obj interface{}) bool {
8482
func viml_equalci(a, b string) bool {
8583
return strings.ToLower(a) == strings.ToLower(b)
8684
}
87-
func viml_eqreg(s, reg string) bool {
88-
if r, ok := patVim2GoRegq[reg]; ok {
89-
return r.MatchString(s)
90-
}
91-
panic(fmt.Errorf("NotImplemented viml_eqreg for %v", reg))
92-
}
9385

9486
func viml_eqregh(s, reg string) bool {
9587
if r, ok := patVim2GoRegh[reg]; ok {
@@ -98,13 +90,6 @@ func viml_eqregh(s, reg string) bool {
9890
panic("NotImplemented viml_eqregh")
9991
}
10092

101-
func viml_eqregq(s, reg string) bool {
102-
if r, ok := patVim2GoRegq[reg]; ok {
103-
return r.MatchString(s)
104-
}
105-
panic("NotImplemented viml_eqregq")
106-
}
107-
10893
func viml_escape(s string, chars string) string {
10994
r := ""
11095
for _, c := range s {

go/vimlfunc_test.go

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,6 @@ import (
55
"testing"
66
)
77

8-
func TestViml_eqreg(t *testing.T) {
9-
tests := []struct {
10-
in string
11-
reg string
12-
want bool
13-
}{
14-
{in: ``, reg: "^\\s*\\\\", want: false},
15-
{in: `hoge`, reg: "^\\s*\\\\", want: false},
16-
{in: ` \ hoge`, reg: "^\\s*\\\\", want: true},
17-
{in: `\`, reg: "^\\s*\\\\", want: true},
18-
19-
// ^++
20-
{in: `++hoge`, reg: "^++", want: true},
21-
{in: `hoge`, reg: "^++", want: false},
22-
23-
// case
24-
{in: `deletel`, reg: "\\v^d%[elete][lp]$", want: true},
25-
{in: `deleteL`, reg: "\\v^d%[elete][lp]$", want: true},
26-
{in: `++bad=keep`, reg: "^++bad=keep", want: true},
27-
{in: `++bad=KEEP`, reg: "^++bad=keep", want: true},
28-
}
29-
for _, tt := range tests {
30-
if got := viml_eqreg(tt.in, tt.reg); got != tt.want {
31-
t.Errorf("viml_eqreg(%q, %q) = %v, want %v", tt.in, tt.reg, got, tt.want)
32-
}
33-
}
34-
}
35-
368
func TestViml_eqregh(t *testing.T) {
379
tests := []struct {
3810
in string
@@ -51,24 +23,6 @@ func TestViml_eqregh(t *testing.T) {
5123
}
5224
}
5325

54-
func TestViml_eqregq(t *testing.T) {
55-
tests := []struct {
56-
in string
57-
reg string
58-
want bool
59-
}{
60-
{in: `deletel`, reg: "\\v^d%[elete][lp]$", want: true},
61-
{in: `deleteL`, reg: "\\v^d%[elete][lp]$", want: true},
62-
{in: `++bad=keep`, reg: "^++bad=keep", want: true},
63-
{in: `++bad=KEEP`, reg: "^++bad=keep", want: true},
64-
}
65-
for _, tt := range tests {
66-
if got := viml_eqregq(tt.in, tt.reg); got != tt.want {
67-
t.Errorf("viml_eqregq(%q, %q) = %v, want %v", tt.in, tt.reg, got, tt.want)
68-
}
69-
}
70-
}
71-
7226
func TestViml_printf(t *testing.T) {
7327
tests := []struct {
7428
f string

0 commit comments

Comments
 (0)