mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 16:59:12 +00:00
feat(wildcard): fast-path some cases (#1747)
* feat(wildcard): fast-path some cases
This commit is contained in:
parent
737184a985
commit
caccaf3e09
2 changed files with 64 additions and 2 deletions
|
@ -52,11 +52,26 @@ func TestMatch(t *testing.T) {
|
|||
text: "tv",
|
||||
matched: true,
|
||||
},
|
||||
{
|
||||
pattern: "t?",
|
||||
text: "tv",
|
||||
matched: true,
|
||||
},
|
||||
{
|
||||
pattern: "?",
|
||||
text: "z",
|
||||
matched: true,
|
||||
},
|
||||
{
|
||||
pattern: "*EPUB*",
|
||||
text: "Translated (Group) / EPUB",
|
||||
matched: true,
|
||||
},
|
||||
{
|
||||
pattern: "*EP?B*",
|
||||
text: "Translated (Group) / EPUB",
|
||||
matched: true,
|
||||
},
|
||||
{
|
||||
pattern: "*shift*",
|
||||
text: "Good show shift S02 2160p ATVP WEB-DL DDP 5.1 Atmos DV HEVC-GROUP",
|
||||
|
@ -110,6 +125,8 @@ func TestMatchSimple(t *testing.T) {
|
|||
{"t?st", "test", false},
|
||||
{"t?st", "tast", false},
|
||||
{"test", "test", true},
|
||||
{"*te?t*", "test", false},
|
||||
{"*test*", "test", true},
|
||||
{"test", "toast", false},
|
||||
{"", "non-empty", false},
|
||||
{"*", "", true},
|
||||
|
@ -160,6 +177,7 @@ func TestMatchSlice(t *testing.T) {
|
|||
}{
|
||||
{[]string{"*", "test", "t?st"}, "test", true},
|
||||
{[]string{"te?t", "t?st", "random"}, "tost", true},
|
||||
{[]string{"te?t", "t??e?", "random"}, "toser", true},
|
||||
{[]string{"*st", "n?st", "l*st"}, "list", true},
|
||||
{[]string{"?", "??", "???"}, "t", true},
|
||||
{[]string{"a", "b", "c"}, "d", false},
|
||||
|
@ -190,3 +208,11 @@ func TestMatchSlice(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Regex(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
b.StartTimer()
|
||||
TestMatchSlice(nil)
|
||||
b.StopTimer()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue