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

VM speedup by using in-place bn.js operators #98

Merged
merged 2 commits into from
Aug 10, 2017
Merged

Conversation

axic
Copy link
Member

@axic axic commented Oct 31, 2016

Replaces #37.

@axic axic force-pushed the feature/speedup branch 2 times, most recently from d1fcf0a to 3dd278d Compare October 31, 2016 22:01
@axic
Copy link
Member Author

axic commented Jun 8, 2017

@cdetrio this could be taken into consideration when testing is working again

@axic axic force-pushed the feature/speedup branch from f367b1b to 8586613 Compare July 28, 2017 18:19
@axic
Copy link
Member Author

axic commented Jul 28, 2017

This one could be merged if the tests pass. There should be a slight speed increase.

@axic
Copy link
Member Author

axic commented Jul 28, 2017

It fails some tests, should be fixed.

@axic axic force-pushed the feature/speedup branch from 8586613 to 394f164 Compare August 10, 2017 21:15
@axic axic force-pushed the feature/speedup branch from 394f164 to bbd85b5 Compare August 10, 2017 21:24
@axic axic requested a review from wanderer August 10, 2017 21:25
@axic
Copy link
Member Author

axic commented Aug 10, 2017

Fixed finally, should pass all tests.

@wanderer wanderer merged commit bb50d99 into master Aug 10, 2017
@axic axic deleted the feature/speedup branch August 10, 2017 23:15
b = new BN(b)

var r
if (b.isZero()) {
r = [0]
} else {
a = new BN(a)
r = a.div(b).toArray('be', 32)
Copy link
Contributor

Choose a reason for hiding this comment

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

can do r = new BN(a).div(b).toArray('be', 32)

Copy link
Member Author

Choose a reason for hiding this comment

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

All this was intentional to keep the change diff small and reviewable. It is going to be replaced by #159 anyway.

b = utils.fromSigned(b)

var r
if (b.isZero()) {
r = Buffer.from([0])
} else {
a = utils.fromSigned(a)
r = utils.toUnsigned(a.div(b))
Copy link
Contributor

Choose a reason for hiding this comment

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

can use r = utils.toUnsigned(utils.fromSigned(a).div(b))

b = new BN(b)
var r
if (b.isZero()) {
r = [0]
} else {
a = new BN(a)
r = a.mod(b).toArray('be', 32)
Copy link
Contributor

Choose a reason for hiding this comment

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

r = new BN(a).mod(b).toArray('be', 32)

b = utils.fromSigned(b)
var r

if (b.isZero()) {
r = Buffer.from([0])
} else {
a = utils.fromSigned(a)
r = a.abs().mod(b.abs())
Copy link
Contributor

Choose a reason for hiding this comment

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

r = utils.fromSigned(a).abs().mod(b.abs())

c = new BN(c)
var r

if (c.isZero()) {
r = [0]
} else {
a = new BN(a).iadd(new BN(b))
r = a.mod(c).toArray('be', 32)
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

c = new BN(c)
var r

if (c.isZero()) {
r = [0]
} else {
a = new BN(a).imul(new BN(b))
r = a.mod(c).toArray('be', 32)
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

holgerd77 pushed a commit that referenced this pull request Dec 14, 2020
* Add leveldb types

* Refactor trie node

* Fix lgtm warnings
holgerd77 added a commit that referenced this pull request Mar 11, 2021
Update mocha to the latest version 🚀
ryanio pushed a commit that referenced this pull request Jan 10, 2022
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.

4 participants