@@ -33,24 +33,26 @@ class FSPermission final : public PermissionBase {
3333
3434 Node () : wildcard_child(nullptr ), is_leaf(false ) {}
3535
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) {
3838 is_leaf = true ;
3939 return this ;
4040 }
41- char label = prefix[0 ];
41+
42+ CHECK (!path_prefix.empty ());
43+ char label = path_prefix[0 ];
4244
4345 Node* child = children[label];
4446 if (child == nullptr ) {
45- children[label] = new Node (prefix );
47+ children[label] = new Node (path_prefix );
4648 return children[label];
4749 }
4850
4951 // swap prefix
5052 size_t i = 0 ;
51- size_t prefix_len = prefix .length ();
53+ size_t prefix_len = path_prefix .length ();
5254 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]) {
5456 std::string parent_prefix = child->prefix .substr (0 , i);
5557 std::string child_prefix = child->prefix .substr (i);
5658
@@ -59,11 +61,11 @@ class FSPermission final : public PermissionBase {
5961 split_child->children [child_prefix[0 ]] = child;
6062 children[parent_prefix[0 ]] = split_child;
6163
62- return split_child->CreateChild (prefix .substr (i));
64+ return split_child->CreateChild (path_prefix .substr (i));
6365 }
6466 }
6567 child->is_leaf = true ;
66- return child->CreateChild (prefix .substr (i));
68+ return child->CreateChild (path_prefix .substr (i));
6769 }
6870
6971 Node* CreateWildcardChild () {
0 commit comments