Skip to content

Commit 2590682

Browse files
committed
Ruby: inline RenderCallUtils::getBaseName
This seems to yield a small performance increase.
1 parent ae3d91b commit 2590682

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

ruby/ql/lib/codeql/ruby/frameworks/Rails.qll

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,13 @@ private module RenderCallUtils {
2929
result = getTemplatePathValue(renderCall).regexpCapture("^/?(.*/)?(?:[^/]*?)$", 1)
3030
}
3131

32-
// everything after the final slash, or the whole string if there is no slash
33-
private string getBaseName(MethodCall renderCall) {
34-
result = getTemplatePathValue(renderCall).regexpCapture("^/?(?:.*/)?([^/]*?)$", 1)
35-
}
36-
3732
/**
3833
* Gets the template file to be rendered by this render call, if any.
3934
*/
4035
ErbFile getTemplateFile(MethodCall renderCall) {
41-
result.getTemplateName() = getBaseName(renderCall) and
36+
// everything after the final slash, or the whole string if there is no slash
37+
result.getTemplateName() =
38+
getTemplatePathValue(renderCall).regexpCapture("^/?(?:.*/)?([^/]*?)$", 1) and
4239
result.getRelativePath().matches("%app/views/" + getSubPath(renderCall) + "%")
4340
}
4441

0 commit comments

Comments
 (0)