Called frequently, must be fast.
| 98 | |
| 99 | // Called frequently, must be fast. |
| 100 | const Protocol* FindProtocol(ProtocolType type) { |
| 101 | const size_t index = type; |
| 102 | if (index >= MAX_PROTOCOL_SIZE) { |
| 103 | LOG(ERROR) << "ProtocolType=" << type << " is out of range"; |
| 104 | return NULL; |
| 105 | } |
| 106 | ProtocolEntry* const protocol_map = get_protocol_map(); |
| 107 | if (protocol_map[index].valid.load(butil::memory_order_acquire)) { |
| 108 | return &protocol_map[index].protocol; |
| 109 | } |
| 110 | return NULL; |
| 111 | } |
| 112 | |
| 113 | void ListProtocols(std::vector<Protocol>* vec) { |
| 114 | vec->clear(); |
no test coverage detected