Python: Fix slow use of regexCapture in Builtin::strValue

This is only _really_ expensive when there are a _lot_ of strings in
the database, but for this case, where we're always extracting the
same substring of the string, it's easier -- and faster -- to just
make a substring operation directly.
This commit is contained in:
Taus Brock-Nannestad
2020-11-05 16:30:19 +01:00
parent 83ba8c9bf5
commit 035e747ad5

View File

@@ -104,7 +104,8 @@ class Builtin extends @py_cobject {
) and
exists(string quoted_string |
quoted_string = this.getName() and
result = quoted_string.regexpCapture("[bu]'([\\s\\S]*)'", 1)
// Remove prefix ("b" or "u") and leading and trailing quotes (both "'").
result = quoted_string.substring(2, quoted_string.length() - 1)
)
}
}