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