* Find the first instruction >= the offset. */
| 103 | * Find the first instruction >= the offset. |
| 104 | */ |
| 105 | Instr *InstrSet::lower_bound(off_t offset) const |
| 106 | { |
| 107 | if (lb == ub) return nullptr; |
| 108 | const Instr *Is = lb; |
| 109 | ssize_t lo = 0, hi = (ub - lb) - 1, mid = 0; |
| 110 | while (lo <= hi) |
| 111 | { |
| 112 | mid = (lo + hi) / 2; |
| 113 | if (offset > (off_t)Is[mid].offset) |
| 114 | lo = mid+1; |
| 115 | else if (offset < (off_t)Is[mid].offset) |
| 116 | hi = mid-1; |
| 117 | else |
| 118 | return (Instr *)&Is[mid]; |
| 119 | } |
| 120 | if ((off_t)Is[mid].offset < offset) |
| 121 | mid++; |
| 122 | return (Is[mid].offset == 0? nullptr: (Instr *)&Is[mid]); |
| 123 | } |
| 124 | |
| 125 | /* |
| 126 | * Find the instruction for the given offset. |
no outgoing calls
no test coverage detected