Skip to content

Commit

Permalink
Add a link to davidben@chromium.org's CL that demonstrates Option<con…
Browse files Browse the repository at this point in the history
…st T&>

It was David who found this optimization opportunity, described there.
  • Loading branch information
danakj committed Sep 13, 2023
1 parent e44f509 commit 4986a51
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sus/option/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ namespace sus {
/// ["null pointer optimization" or NPO in Rust](
/// https://doc.rust-lang.org/stable/std/option/index.html#representation).
///
/// # References
/// # Reference parameters
///
/// As mentioned above [`Option`]($sus::option::Option) type can hold a
/// reference, which allows code to use `Option<const T&>` or `Option<T&>`
Expand All @@ -200,7 +200,9 @@ namespace sus {
/// become empty/non-empty. This is a common optimization pitfall with
/// [`std::optional`](https://en.cppreference.com/w/cpp/utility/optional).
///
/// As an example, this code is optimized poorly, keeping a runtime check on
/// As an example, this code is [optimized poorly](
/// https://chromium-review.googlesource.com/c/chromium/src/+/4860473),
/// keeping a runtime check on
/// the [`Option`]($sus::option::Option). Global analysis could perhaps show it
/// not required, but it is beyond the view of the compiler.
/// ```
Expand Down

0 comments on commit 4986a51

Please sign in to comment.