-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanups related to
LookupInMap
and other template functions.
- `obu_util.h`: Tweak generic "validation"-themed template functions - Standardize use of `absl::string_view` for `context` (vs. `std::string`). - Add `likely/unlikely` [attributes](https://en.cppreference.com/w/cpp/language/attributes/likely). Mostly these are used for the "happy case", and lead to downstream unrecoverable failures when they fail. - Map lookups: - Unify naming to prefer `CopyFrom*` when lookups write to an output argument. - Rename existing template to `CopyFromMap` because it uses this style. - Unify naming to prefer `LookupFrom*` for lookups that return `StatusOr<T>`. - Add a new `LookupFromMap` template which uses this style. Use it throughout codebase. - Pass key by const reference, in case it is a complex type. - Update both templates to have a `context` string. - With the context string, and the template logging the key which caused lookup to fail, we can cleanup a lot of boiler-plate for lookup failures and rely on the template to handle the logging. - Standardize "context" language when lookup fails a bit. - Switch to `absl::NotFoundError` when lookup fails, which seems more canonical. - Drive-by: This triggered a stray test failure. Update it to prefer not checking explicit error codes. - Switch some underlying map types to use `absl::string_view` instead of `std::string`. PiperOrigin-RevId: 689810011
- Loading branch information
Showing
23 changed files
with
205 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.