GyulyVGC / sniffnet

Comfortably monitor your Internet traffic 🕵️‍♂️
https://sniffnet.net
Apache License 2.0
17.94k stars 548 forks source link

Reduce usage of `String` in translations code. #524

Closed CosminPerRam closed 3 months ago

CosminPerRam commented 5 months ago

This is a part of #523 (the non-lint part of it). This PR removes an unnecessary to_string call on an already String value and replaces per-item .to_string() with an entire match block .to_string().

GyulyVGC commented 5 months ago

Thanks!

While you are at it, would you mind updating all the translations methods to return an &'static str?

I think there are some cases where I actually don't need them to be strings, so this should be more efficient.

In cases Strings are actually needed, it'd be nice updating the code where the function is invoked calling .to_string() and leaving &str as return value of the method.

CosminPerRam commented 5 months ago

Although there is a mix usage of &'static str, String and Text<'static, StyleType>, I ought here to replace only the non-parameter-composing String instances as replacing Text ones would require bigger changes (that can be done in another PR).

GyulyVGC commented 5 months ago

Although there is a mix usage of &'static str, String and Text<'static, StyleType>, I ought here to replace only the non-parameter-composing String instances as replacing Text ones would require bigger changes (that can be done in another PR).

I agree, and I'm fine with this.

GyulyVGC commented 3 months ago

@all-contributors please add @CosminPerRam for code.

allcontributors[bot] commented 3 months ago

@GyulyVGC

I've put up a pull request to add @CosminPerRam! :tada: