Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error strings lazily #425

Closed
eyalroz opened this issue Oct 8, 2022 · 0 comments
Closed

Build error strings lazily #425

eyalroz opened this issue Oct 8, 2022 · 0 comments

Comments

@eyalroz
Copy link
Owner

eyalroz commented Oct 8, 2022

We may currently be wasting a lot of time building error strings, for all those throw_if_error() calls.

Instead, we should arrange it so that no string is built except when there's an error.

Ways this can happen:

  1. Pass a lambda which returns the string; it doesn't get evaluated except when necessary.
  2. Make throw_if_error() a macro (possibly a variadic macro taking many strings)
  3. Make throw_if_error() an (inlined) variadic template function which takes string-like objects. Their concatenation can happen conditionally within the function body (e.g. using a for_each_arg and such).
@eyalroz eyalroz added the task label Oct 8, 2022
eyalroz added a commit that referenced this issue Oct 9, 2022
* Added `throw_if_error_lazy()`, a macro alternative to the `throw_if_error()` function, which constructs the message string only when actually throwing an error
* Using throw_if_error_lazy()` extensively in the API wrapper implementations
eyalroz added a commit that referenced this issue Oct 10, 2022
* Added `throw_if_error_lazy()`, a macro alternative to the `throw_if_error()` function, which constructs the message string only when actually throwing an error
* Using throw_if_error_lazy()` extensively in the API wrapper implementations
@eyalroz eyalroz self-assigned this Oct 10, 2022
eyalroz added a commit that referenced this issue Oct 10, 2022
* Added `throw_if_error_lazy()`, a macro alternative to the `throw_if_error()` function, which constructs the message string only when actually throwing an error
* Using throw_if_error_lazy()` extensively in the API wrapper implementations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant