friedPotat0 / Spam-Scores

Thunderbird add-on to display spam scores according to mail headers. Supports spam/ham score headers of Rspamd and SpamAssassin. The add-on adds a column with the overall spam score to the mail list view and shows details of any matched spam/ham rule.
https://addons.thunderbird.net/de/thunderbird/addon/spam-scores/
Other
42 stars 6 forks source link

Code Optimization and ES6 Modules #36

Closed dlh2 closed 2 years ago

dlh2 commented 2 years ago

I swapped your if replace to a for of and it seems faster:

image

Your RegEx seemed to odd for me, so I tried to change it and voilá a lot faster:

image

Later I found you make redundancy about the Bounds, so we'll make a function and let the job do on there.

Also, I suggest to use "Let" whenever the variable is going to change after.

dlh2 commented 2 years ago

We can enhance the code by using ES6 Modules so it's neatly rearranged, I'm not sure if you really want to change it as it will change the way we code xD

dlh2 commented 2 years ago

Two background files, let's do what we said at #35

friedPotat0 commented 2 years ago

Sounds good! We should import the DEFAULT_SCORE_LOWER_BOUNDS and DEFAULT_SCORE_UPPER_BOUNDS constant in options.js and experiments.js from the new constants file.

Furthermore there are some redundancies in the custom_score_column.js like the ones you have just fixed in the background.js. It would be good to optimize those, too.

Thanks again for the very good contributions!

dlh2 commented 2 years ago

On my way, I'm changing this little by little

dlh2 commented 2 years ago

experiment_apis aren't compatible with ES6 modules