We are doing a lot of cloneing of the backtraces we generate in inner error types when converting Kinds into their wrapper types in From impls. If this proves to have substantial performance implications, we should replace the backtrace fields on the outer types with methods that return a reference to the backtrace fields on the wrapped “kind” types.
For example, we might have a type ApiErrorKind that looks something like
struct ApiErrorKind {
...
backtrace: Backtrace,
...
}
and a wrapper type ApiError that looks like
struct ApiError {
...
kind: ApiErrorKind,
backtrace: Backtrace,
...
}
where the backtrace field in ApiError is a clone of the backtrace field in ApiErrorKind. Instead of cloning that field, we could implement a method on ApiError like so:
impl ApiError {
fn backtrace(&self) -> &Backtrace {
&self.kind.backtrace
}
}
┆Issue is synchronized with this Jira Task
We are doing a lot of
cloneing of the backtraces we generate in inner error types when convertingKinds into their wrapper types inFromimpls. If this proves to have substantial performance implications, we should replace thebacktracefields on the outer types with methods that return a reference to thebacktracefields on the wrapped “kind” types.For example, we might have a type
ApiErrorKindthat looks something likeand a wrapper type
ApiErrorthat looks likewhere the
backtracefield inApiErroris a clone of thebacktracefield inApiErrorKind. Instead of cloning that field, we could implement a method onApiErrorlike so:┆Issue is synchronized with this Jira Task