Skip to content

refactor: use new return type internally#72

Merged
bifurcation merged 5 commits intocisco:mainfrom
k-wasniowski:refactor-to-use-result-type-part-1
Mar 5, 2026
Merged

refactor: use new return type internally#72
bifurcation merged 5 commits intocisco:mainfrom
k-wasniowski:refactor-to-use-result-type-part-1

Conversation

@k-wasniowski
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread include/sframe/result.h Outdated
Comment thread include/sframe/result.h Outdated
Comment thread include/sframe/result.h Outdated
Comment thread include/sframe/result.h Outdated
Comment thread include/sframe/result.h
Comment thread include/sframe/result.h Outdated
Comment thread include/sframe/result.h
Comment thread include/sframe/result.h
Comment thread include/sframe/result.h Outdated
Comment thread test/header.cpp Outdated
@k-wasniowski k-wasniowski force-pushed the refactor-to-use-result-type-part-1 branch from c9673f6 to da4c885 Compare February 24, 2026 10:56
Comment thread include/sframe/result.h
// Unwrap a Result<T> into `var`, propagating the error by early return.
// Use in functions that already return Result<U>.
// Usage: SFRAME_VALUE_OR_RETURN(val, some_result_expr);
#define SFRAME_VALUE_OR_RETURN(var, expr) \
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could also update both macro's to be more "chromium' like.
Chromium have something like ASSIGN_OR_RETURN. Which works very similarly to our SFRAME_VALUE_OR_RETURN. The one difference is that chromium approach allows you to specify a type of the variable.
Usage of SFRAME_VALUE_OR_RETURN:

SFRAME_VALUE_OR_RETURN(value, decode_uint(data.subspan(0, size)));

Meanwhile, chromium is like:

ASSIGN_OR_RETURN(uint64_t size_per_site, GetDictionarySizePerSite(top_frame_site));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bifurcation Which one you would prefer?
I believe the chromium version makes it a little bit more readable in terms of typing. (you can always use auto inside google version aswell)

@bifurcation bifurcation merged commit 2d84b74 into cisco:main Mar 5, 2026
@k-wasniowski k-wasniowski deleted the refactor-to-use-result-type-part-1 branch March 10, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants