Skip to content

Commit c6a7b8f

Browse files
committed
DLT SomeIP: Check for constant boolean directly
* Check for constant bool `CAN_ERROR` directly method without the need to an extra method to access it. * Remove the unneeded inline method
1 parent 46ba96e commit c6a7b8f

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

application/apps/indexer/parsers/src/lib.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,10 @@ where
154154
}
155155

156156
pub trait LogMessage: Serialize {
157+
//TODO AAZ: Measure this an remove if rust already optimize the code without it.
157158
/// Indicates that parsing this struct to text can error.
158159
const CAN_ERROR: bool;
159160

160-
//TODO AAZ: Measure this an remove if rust already optimize the code without it.
161-
#[inline(always)]
162-
fn can_error(&self) -> bool {
163-
<Self as LogMessage>::CAN_ERROR
164-
}
165-
166161
/// Serializes a message directly into a Writer
167162
/// returns the size of the serialized message
168163
fn to_writer<W: Write>(&self, writer: &mut W) -> Result<usize, std::io::Error>;

application/apps/indexer/session/src/parse_err.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ impl ParseErrorReslover {
4444
/// Get the text message of [`LogMessage`], resolving parse text errors if possible,
4545
/// TODO: Otherwise it should save the error to the faulty messages store, which need to be
4646
/// implemented as well :)
47-
pub fn get_log_text(item: impl LogMessage, err_resolver: &mut ParseErrorReslover) -> String {
47+
pub fn get_log_text<T: LogMessage>(item: T, err_resolver: &mut ParseErrorReslover) -> String {
4848
let text_res = item.to_text();
49-
if item.can_error() {
49+
if T::CAN_ERROR {
5050
let mut msg = text_res.msg;
5151
if let Some(err_info) = text_res.error {
5252
match err_resolver.resolve_err(&err_info) {

0 commit comments

Comments
 (0)