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

Further refactors #33

Merged
merged 6 commits into from
Oct 8, 2023
Merged

Further refactors #33

merged 6 commits into from
Oct 8, 2023

Conversation

chris-ha458
Copy link
Contributor

I am restricting visibility as much as possible right now.
(Minimal pub and when necessary pub(crate), pub(super) )

This would allow for cleaner implementations, outside api and hopefully allow more compiler optimizations.

this slightly changes early calc periods (off by 1) and technically might cause double calculation when `length == threshold`
but it saves 2 comparisons every lopp that is only relevant first and last case.
src/md.rs Outdated
flags,
unicode_range: range,
}
detectors.iter().map(|x| x.ratio()).sum()
Copy link
Owner

Choose a reason for hiding this comment

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

why it is here instead of mean_mess_ratio?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was trying to redo calculations in case of index ==0 (which I skip now)

i realize it is wrong because it has to be recalculated before the trace as well.

7e085a5 fixes it but ensures double calc most of the time.

There are multiple ways to reduce this double calc including
using mean_mess_ratio: Option<f32> or calling a early return function instead of break in the if.

I've tried both and they work, but introduces a bit of complexity so i am keeping it simple for now.

Copy link
Owner

Choose a reason for hiding this comment

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

Maybe we could use condition if log_enabled!(Level::Trace) , see https://docs.rs/env_logger/latest/env_logger/ ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since there are other places where the trace exists, maybe addressing that could be part of another pr?

Copy link
Owner

@nickspring nickspring Oct 8, 2023

Choose a reason for hiding this comment

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

I don't think so. It is only one place when we have additional calculation because of logs. You could use this if to avoid double calculation of mean_mess_ratio.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

d442d08
removes recalc.
I'll look to integrate if log_enabled!(Level::Trace)

@nickspring nickspring merged commit d0d32ae into nickspring:main Oct 8, 2023
3 checks passed
@chris-ha458 chris-ha458 deleted the refactor_1 branch October 8, 2023 23:12
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