| 25 | |
| 26 | template<typename Iter> |
| 27 | typename std::iterator_traits<Iter>::value_type const *binary_find(Iter begin, Iter end, const char *name) { |
| 28 | auto it = std::lower_bound(begin, end, name, [](const auto &lhs, const char *rhs) { |
| 29 | return strcmp(lhs.name, rhs) < 0; |
| 30 | }); |
| 31 | |
| 32 | if (it == end || strcmp(name, it->name) != 0) { |
| 33 | return nullptr; |
| 34 | } |
| 35 | else { |
| 36 | return &(*it); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | const IFaceConstant *IFaceTable::FindConstant(const char *name) const { |
| 41 | return binary_find(constants.cbegin(), constants.cend(), name); |
no outgoing calls
no test coverage detected