| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,24 +33,26 @@ class FSPermission final : public PermissionBase { | |||
| 33 | 33 | ||
| 34 | 34 | Node() : wildcard_child(nullptr), is_leaf(false) {} | |
| 35 | 35 | ||
| 36 | - Node* CreateChild(const std::string& prefix) { | ||
| 37 | - if (prefix.empty() && !is_leaf) { | ||
| 36 | + Node* CreateChild(const std::string& path_prefix) { | ||
| 37 | + if (path_prefix.empty() && !is_leaf) { | ||
| 38 | 38 | is_leaf = true; | |
| 39 | 39 | return this; | |
| 40 | 40 | } | |
| 41 | - char label = prefix[0]; | ||
| 41 | + | ||
| 42 | + CHECK(!path_prefix.empty()); | ||
| 43 | + char label = path_prefix[0]; | ||
| 42 | 44 | ||
| 43 | 45 | Node* child = children[label]; | |
| 44 | 46 | if (child == nullptr) { | |
| 45 | - children[label] = new Node(prefix); | ||
| 47 | + children[label] = new Node(path_prefix); | ||
| 46 | 48 | return children[label]; | |
| 47 | 49 | } | |
| 48 | 50 | ||
| 49 | 51 | // swap prefix | |
| 50 | 52 | size_t i = 0; | |
| 51 | - size_t prefix_len = prefix.length(); | ||
| 53 | + size_t prefix_len = path_prefix.length(); | ||
| 52 | 54 | for (; i < child->prefix.length(); ++i) { | |
| 53 | - if (i > prefix_len || prefix[i] != child->prefix[i]) { | ||
| 55 | + if (i > prefix_len || path_prefix[i] != child->prefix[i]) { | ||
| 54 | 56 | std::string parent_prefix = child->prefix.substr(0, i); | |
| 55 | 57 | std::string child_prefix = child->prefix.substr(i); | |
| 56 | 58 | ||
@@ -59,11 +61,11 @@ class FSPermission final : public PermissionBase { | |||
| 59 | 61 | split_child->children[child_prefix[0]] = child; | |
| 60 | 62 | children[parent_prefix[0]] = split_child; | |
| 61 | 63 | ||
| 62 | - return split_child->CreateChild(prefix.substr(i)); | ||
| 64 | + return split_child->CreateChild(path_prefix.substr(i)); | ||
| 63 | 65 | } | |
| 64 | 66 | } | |
| 65 | 67 | child->is_leaf = true; | |
| 66 | - return child->CreateChild(prefix.substr(i)); | ||
| 68 | + return child->CreateChild(path_prefix.substr(i)); | ||
| 67 | 69 | } | |
| 68 | 70 | ||
| 69 | 71 | Node* CreateWildcardChild() { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments