\brief Given \a key, returns its corresponding value. \param[in] key The key to look up. This must not be `nullptr`, nor an empty string. It must not contain embedded `NUL`s. \return The corresponding value for \a key, or if \a key is not found, `nullptr`.
| 134 | //! \return The corresponding value for \a key, or if \a key is not found, |
| 135 | //! `nullptr`. |
| 136 | const char* GetValueForKey(std::string_view key) const { |
| 137 | DCHECK(key.data()); |
| 138 | DCHECK(key.size()); |
| 139 | DCHECK_EQ(key.find('\0', 0), std::string_view::npos); |
| 140 | if (!key.data() || !key.size()) { |
| 141 | return nullptr; |
| 142 | } |
| 143 | |
| 144 | const Entry* entry = GetConstEntryForKey(key); |
| 145 | if (!entry) { |
| 146 | return nullptr; |
| 147 | } |
| 148 | |
| 149 | return entry->value; |
| 150 | } |
| 151 | |
| 152 | //! \brief Stores \a value into \a key, replacing the existing value if \a key |
| 153 | //! is already present. |