| 638 | } |
| 639 | |
| 640 | PathMatcher::NodePtr PathMatcher::addPathsWalk( Node *node, const Node *srcNode, bool shared, bool &added ) |
| 641 | { |
| 642 | shared = shared || node->refCount() > 1; |
| 643 | |
| 644 | NodePtr result; |
| 645 | if( !node->terminator && srcNode->terminator ) |
| 646 | { |
| 647 | added = true; |
| 648 | writable( node, result, shared )->terminator = true; |
| 649 | } |
| 650 | |
| 651 | for( Node::ChildMap::const_iterator it = srcNode->children.begin(), eIt = srcNode->children.end(); it != eIt; ++it ) |
| 652 | { |
| 653 | Node *srcChild = it->second.get(); |
| 654 | NodePtr newChild; |
| 655 | if( Node *child = node->child( it->first ) ) |
| 656 | { |
| 657 | if( child != srcChild ) |
| 658 | { |
| 659 | newChild = addPathsWalk( child, srcChild, shared, added ); |
| 660 | } |
| 661 | } |
| 662 | else |
| 663 | { |
| 664 | newChild = srcChild; |
| 665 | added = true; // source node can only exist if it or a descendant is a terminator |
| 666 | } |
| 667 | if( newChild ) |
| 668 | { |
| 669 | writable( node, result, shared )->children[it->first] = newChild; |
| 670 | } |
| 671 | } |
| 672 | |
| 673 | return result; |
| 674 | } |
| 675 | |
| 676 | PathMatcher::NodePtr PathMatcher::addPrefixedPathsWalk( Node *node, const Node *srcNode, const NameIterator &start, const NameIterator &end, bool shared, bool &added ) |
| 677 | { |