-
Notifications
You must be signed in to change notification settings - Fork 8
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
Timo/fix quadr complexity #11
base: master
Are you sure you want to change the base?
Conversation
Nat32.fromIntWrap(Nat8.toNat(p[j + 1])) << 16 | | ||
Nat32.fromIntWrap(Nat8.toNat(p[j + 2])) << 08 | | ||
Nat32.fromIntWrap(Nat8.toNat(p[j + 3])) << 00; | ||
Nat32.fromIntWrap(Nat8.toNat(data[start + j + 0])) << 24 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't these just be Nat32.fromNat or do you want to avoid the redundant overflow check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean Nat32.fromNat(Nat8.toNat(..))?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. But perhaps the existing is faster since it doesn't check for overflow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it. fromIntWrap is slightly cheaper than fromNat.
while (p.size() >= 64) { | ||
var start = 0; | ||
var len = data.size(); | ||
while (len >= 64) { | ||
var j = 0; | ||
for (i in Iter.range(0, 15)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The for loop might be quicker as a while loop starting j from start, incrementing by 4 up to a pre-computed bound.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But i
has to increment, too.
Why exactly would it be quicker?
Copying the whole data with every chunk caused quadratic complexity.