| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 08a819c commit 365d44f
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -53,54 +53,6 @@ | |||
| 53 | 53 | __all__ = ("TreeModifier", "Tree") | |
| 54 | 54 | ||
| 55 | 55 | ||
| 56 | - def git_cmp(t1: TreeCacheTup, t2: TreeCacheTup) -> int: | ||
| 57 | - a, b = t1[2], t2[2] | ||
| 58 | - # assert isinstance(a, str) and isinstance(b, str) | ||
| 59 | - len_a, len_b = len(a), len(b) | ||
| 60 | - min_len = min(len_a, len_b) | ||
| 61 | - min_cmp = cmp(a[:min_len], b[:min_len]) | ||
| 62 | - | ||
| 63 | - if min_cmp: | ||
| 64 | - return min_cmp | ||
| 65 | - | ||
| 66 | - return len_a - len_b | ||
| 67 | - | ||
| 68 | - | ||
| 69 | - def merge_sort(a: List[TreeCacheTup], cmp: Callable[[TreeCacheTup, TreeCacheTup], int]) -> None: | ||
| 70 | - if len(a) < 2: | ||
| 71 | - return | ||
| 72 | - | ||
| 73 | - mid = len(a) // 2 | ||
| 74 | - lefthalf = a[:mid] | ||
| 75 | - righthalf = a[mid:] | ||
| 76 | - | ||
| 77 | - merge_sort(lefthalf, cmp) | ||
| 78 | - merge_sort(righthalf, cmp) | ||
| 79 | - | ||
| 80 | - i = 0 | ||
| 81 | - j = 0 | ||
| 82 | - k = 0 | ||
| 83 | - | ||
| 84 | - while i < len(lefthalf) and j < len(righthalf): | ||
| 85 | - if cmp(lefthalf[i], righthalf[j]) <= 0: | ||
| 86 | - a[k] = lefthalf[i] | ||
| 87 | - i = i + 1 | ||
| 88 | - else: | ||
| 89 | - a[k] = righthalf[j] | ||
| 90 | - j = j + 1 | ||
| 91 | - k = k + 1 | ||
| 92 | - | ||
| 93 | - while i < len(lefthalf): | ||
| 94 | - a[k] = lefthalf[i] | ||
| 95 | - i = i + 1 | ||
| 96 | - k = k + 1 | ||
| 97 | - | ||
| 98 | - while j < len(righthalf): | ||
| 99 | - a[k] = righthalf[j] | ||
| 100 | - j = j + 1 | ||
| 101 | - k = k + 1 | ||
| 102 | - | ||
| 103 | - | ||
| 104 | 56 | class TreeModifier: | |
| 105 | 57 | """A utility class providing methods to alter the underlying cache in a list-like fashion. | |
| 106 | 58 | ||
@@ -131,7 +83,7 @@ def set_done(self) -> "TreeModifier": | |||
| 131 | 83 | ||
| 132 | 84 | :return self: | |
| 133 | 85 | """ | |
| 134 | - merge_sort(self._cache, git_cmp) | ||
| 86 | + self._cache.sort(key=lambda x: (x[2] + "/") if x[1] == Tree.tree_id << 12 else x[2]) | ||
| 135 | 87 | return self | |
| 136 | 88 | ||
| 137 | 89 | # } END interface | |
| Back | FazBrowse Home | New Git URL |
0 commit comments