shssoichiro/zxcvbn-rs

Performance and ideomatic code

ThomasdenH opened this issue · 4 comments

I have some ideas that would improve performance and ideomaticy (is that a word?).

I think the properties of Entropy are better private and can then be coverted to methods. The crack times and score can be computed lazily if needed by the user.

Feeback should probably use enums Warning and Suggestion that implement Display. This would close #16.

I think some allocations can be prevented. It could be difficult, but I think the field token in Match could be a &str that borrows from password. Match could also have a reference to password and compute the correct slice in a method when needed.

Thanks, I like these suggestions and they look good to go into a 2.0 release. The current implementation was designed to be similar to the JS implementation, but as long as the calculations remain the same, I'm open to making the interface more Rust-like.

but as long as the calculations remain the same, I'm open to making the interface more Rust-like.

@shssoichiro could you release a .wasm and enscripten js build so we can run easily run the same version in the browser and on the server?

Most of this issue is done, so I opened #28 and will close this.