Skip to content

Commit 512f9d5

Browse files
Update codeflash/languages/java/import_resolver.py
Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com>
1 parent f73c673 commit 512f9d5

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

codeflash/languages/java/import_resolver.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,10 @@ def _extract_class_name(self, import_path: str) -> str | None:
216216
"""
217217
if not import_path:
218218
return None
219-
parts = import_path.split(".")
220-
if parts:
221-
last_part = parts[-1]
222-
# Check if it looks like a class name (starts with uppercase)
223-
if last_part and last_part[0].isupper():
224-
return last_part
219+
# Use rpartition to avoid allocating a list from split()
220+
last_part = import_path.rpartition(".")[2]
221+
if last_part and last_part[0].isupper():
222+
return last_part
225223
return None
226224

227225
def find_class_file(self, class_name: str, package_hint: str | None = None) -> Path | None:

0 commit comments

Comments
 (0)