( hookStack: ParsedStackFrame[], rootStack: ParsedStackFrame[], rootIndex: number, )
| 845 | let mostLikelyAncestorIndex = 0; |
| 846 | |
| 847 | function findSharedIndex( |
| 848 | hookStack: ParsedStackFrame[], |
| 849 | rootStack: ParsedStackFrame[], |
| 850 | rootIndex: number, |
| 851 | ) { |
| 852 | const source = rootStack[rootIndex].source; |
| 853 | hookSearch: for (let i = 0; i < hookStack.length; i++) { |
| 854 | if (hookStack[i].source === source) { |
| 855 | // This looks like a match. Validate that the rest of both stack match up. |
| 856 | for ( |
| 857 | let a = rootIndex + 1, b = i + 1; |
| 858 | a < rootStack.length && b < hookStack.length; |
| 859 | a++, b++ |
| 860 | ) { |
| 861 | if (hookStack[b].source !== rootStack[a].source) { |
| 862 | // If not, give up and try a different match. |
| 863 | continue hookSearch; |
| 864 | } |
| 865 | } |
| 866 | return i; |
| 867 | } |
| 868 | } |
| 869 | return -1; |
| 870 | } |
| 871 | |
| 872 | function findCommonAncestorIndex( |
| 873 | rootStack: ParsedStackFrame[], |
no outgoing calls
no test coverage detected