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

Use irand instead of int rand in Main.pm. #406

Closed
svenoe opened this issue Sep 1, 2020 · 4 comments
Closed

Use irand instead of int rand in Main.pm. #406

svenoe opened this issue Sep 1, 2020 · 4 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@svenoe
Copy link
Contributor

svenoe commented Sep 1, 2020

According to https://metacpan.org/pod/Math::Random::Secure this should be faster. Kernel/System/Main.pm uses int rand in sub GenerateRandomString.

@svenoe svenoe added this to the OTOBO 10.1 milestone Sep 1, 2020
@bschmalhofer
Copy link
Contributor

bschmalhofer commented Sep 1, 2020

@svenoe , while you are at it cou convert the sub to calling Math::Random::Secure::irand() only once and then convert the result to base 62, that is to a string containing only the 62 characters in [0-9][a-z][A-Z].

@svenoe
Copy link
Contributor Author

svenoe commented Sep 1, 2020

Yes, I thought about that, although you can call this for variable dictionaries and string lengths, and so some calculating has to be done, and one time won't be enough, if your string exceeds 32bit of information, as I understand it.

@bschmalhofer bschmalhofer added the enhancement New feature or request label Sep 4, 2020
@bschmalhofer bschmalhofer self-assigned this Sep 4, 2020
bschmalhofer added a commit that referenced this issue Sep 4, 2020
Might be slightly faster.
bschmalhofer added a commit that referenced this issue Sep 4, 2020
bschmalhofer added a commit that referenced this issue Sep 4, 2020
namespace::clean is no new dependency, as it already was required by Moo
@bschmalhofer
Copy link
Contributor

bschmalhofer commented Sep 4, 2020

I also noted that the namespace Kernel::System::Main is not very clean. Various subroutines are imported into the namespace which are subsequently available as methods on the Main object. use namespace::autoclean;can do the cleaning up. This module is not a new dependency, as it is already implicitly required because of the module Moo. See also http://perladvent.org/2011/2011-12-03.html.

bschmalhofer added a commit that referenced this issue Sep 4, 2020
ARG could cause layer cache invalidation
@bschmalhofer
Copy link
Contributor

Tests look fine. Closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants