(ntyp nodeTyp, label byte)
| 544 | } |
| 545 | |
| 546 | func (n *node) findEdge(ntyp nodeTyp, label byte) *node { |
| 547 | nds := n.children[ntyp] |
| 548 | num := len(nds) |
| 549 | idx := 0 |
| 550 | |
| 551 | switch ntyp { |
| 552 | case ntStatic, ntParam, ntRegexp: |
| 553 | i, j := 0, num-1 |
| 554 | for i <= j { |
| 555 | idx = i + (j-i)/2 |
| 556 | if label > nds[idx].label { |
| 557 | i = idx + 1 |
| 558 | } else if label < nds[idx].label { |
| 559 | j = idx - 1 |
| 560 | } else { |
| 561 | i = num // breaks cond |
| 562 | } |
| 563 | } |
| 564 | if nds[idx].label != label { |
| 565 | return nil |
| 566 | } |
| 567 | return nds[idx] |
| 568 | |
| 569 | default: // catch all |
| 570 | return nds[idx] |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | func (n *node) isLeaf() bool { |
| 575 | return n.endpoints != nil |
no outgoing calls
no test coverage detected