Find the longest common prefix of two strings.
| 37 | |
| 38 | // Find the longest common prefix of two strings. |
| 39 | absl::string_view FindLongestCommonPrefix(absl::string_view a, |
| 40 | absl::string_view b) { |
| 41 | if (a.empty() || b.empty()) return absl::string_view(); |
| 42 | |
| 43 | const char* pa = a.data(); |
| 44 | const char* pb = b.data(); |
| 45 | size_t count = 0; |
| 46 | const size_t limit = std::min(a.size(), b.size()); |
| 47 | while (count < limit && *pa == *pb) { |
| 48 | ++pa; |
| 49 | ++pb; |
| 50 | ++count; |
| 51 | } |
| 52 | |
| 53 | return absl::string_view(a.data(), count); |
| 54 | } |
| 55 | |
| 56 | string LogName(const Operator& op) { |
| 57 | const string& opname = HelpfulOperatorTypeName(op); |