Skip to content

Commit fe1db5f

Browse files
authored
Merge pull request #626 from guykisel/case_conflict_performance
optimize check_case_conflict.parents
2 parents e71fd49 + 2468167 commit fe1db5f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pre_commit_hooks/check_case_conflict.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import argparse
2-
import os.path
32
from typing import Iterable
43
from typing import Iterator
54
from typing import Optional
@@ -15,10 +14,11 @@ def lower_set(iterable: Iterable[str]) -> Set[str]:
1514

1615

1716
def parents(file: str) -> Iterator[str]:
18-
file = os.path.dirname(file)
19-
while file:
20-
yield file
21-
file = os.path.dirname(file)
17+
path_parts = file.split('/')
18+
path_parts.pop()
19+
while path_parts:
20+
yield '/'.join(path_parts)
21+
path_parts.pop()
2222

2323

2424
def directories_for(files: Set[str]) -> Set[str]:

0 commit comments

Comments
 (0)