@@ -32,24 +32,26 @@ class FSPermission final : public PermissionBase {
3232
3333      Node () : wildcard_child(nullptr ), is_leaf(false ) {}
3434
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) {
3737          is_leaf = true ;
3838          return  this ;
3939        }
40-         char  label = prefix[0 ];
40+ 
41+         CHECK (!path_prefix.empty ());
42+         char  label = path_prefix[0 ];
4143
4244        Node* child = children[label];
4345        if  (child == nullptr ) {
44-           children[label] = new  Node (prefix );
46+           children[label] = new  Node (path_prefix );
4547          return  children[label];
4648        }
4749
4850        //  swap prefix
4951        size_t  i = 0 ;
50-         size_t  prefix_len = prefix .length ();
52+         size_t  prefix_len = path_prefix .length ();
5153        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]) {
5355            std::string parent_prefix = child->prefix .substr (0 , i);
5456            std::string child_prefix = child->prefix .substr (i);
5557
@@ -58,11 +60,11 @@ class FSPermission final : public PermissionBase {
5860            split_child->children [child_prefix[0 ]] = child;
5961            children[parent_prefix[0 ]] = split_child;
6062
61-             return  split_child->CreateChild (prefix .substr (i));
63+             return  split_child->CreateChild (path_prefix .substr (i));
6264          }
6365        }
6466        child->is_leaf  = true ;
65-         return  child->CreateChild (prefix .substr (i));
67+         return  child->CreateChild (path_prefix .substr (i));
6668      }
6769
6870      Node* CreateWildcardChild () {
0 commit comments