Skip to content

Commit 28741dd

Browse files
author
Mark Shannon
authored
Merge pull request #1433 from aeyerstaylor/faster-python
Python: Improve performance of submodule name computation.
2 parents 9c79959 + e66c132 commit 28741dd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

python/ql/src/semmle/python/objects/Modules.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,12 @@ class PackageObjectInternal extends ModuleObjectInternal, TPackageObject {
155155

156156
/** Gets the submodule `name` of this package */
157157
ModuleObjectInternal submodule(string name) {
158-
result.getName() = this.getName() + "." + name
158+
exists(string fullName, int lastDotIndex |
159+
fullName = result.getName() and
160+
lastDotIndex = max(fullName.indexOf(".")) and
161+
name = fullName.substring(lastDotIndex + 1, fullName.length()) and
162+
this.getName() = fullName.substring(0, lastDotIndex)
163+
)
159164
}
160165

161166
override int intValue() {

0 commit comments

Comments
 (0)