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

Just some speed optimizations #52

Merged
merged 2 commits into from
Sep 9, 2014
Merged

Just some speed optimizations #52

merged 2 commits into from
Sep 9, 2014

Conversation

rindeal
Copy link
Contributor

@rindeal rindeal commented Sep 9, 2014

No description provided.

@@ -126,7 +126,8 @@ public function randomizeFilter($original, $offset = 0)
$random = array_slice($original, $offset);
shuffle($random);

for ($x=0; $x < sizeof($original); $x++) {
$sizeOf = sizeof($original);
for ($x=0; $x < $sizeOf; $x++) {
Copy link
Member

Choose a reason for hiding this comment

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

Can save one line by doing for ($x = 0, $sizeOf = sizeof($original); $x < $sizeOf; $x++) { and $sizeOf will still be cached 😃

@w00fz
Copy link
Member

w00fz commented Sep 9, 2014

I like these changes, json_encode should be much faster than serialize, did you benchmark this by any chance? Curious about the difference.

@rindeal
Copy link
Contributor Author

rindeal commented Sep 9, 2014

No, I haven't, but I've benchmarked sizeof caching and it gets about 70-80% faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants