-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
improve clone #32
improve clone #32
Conversation
popomore
commented
Aug 28, 2014
- clone history
- option for deep clone, default: false
- option for cloneBuffer, default: true
- use node-v8-clone for performance, fallback to lodash
- add jshintrc to check code style
var _ = require('lodash'); | ||
var cloneDeep = _.cloneDeep; | ||
|
||
var cloneBuffer = require('./lib/cloneBuffer'); |
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.
is this needed with node-v8-clone?
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.
cloneBuffer just copy buffer, don't require clone.
} | ||
}, this); | ||
|
||
clone.contents = this.isBuffer() ? cloneBuffer(this.contents) : this.contents; | ||
clone.stat = this.stat ? cloneStats(this.stat) : null; | ||
file.contents = opt.contents && this.isBuffer() ? cloneBuffer(this.contents) : this.contents; |
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.
want to send another pull request adding in the stream dereferencing?
@contra using a native dep is not a good idea for a myriad of reasons:
|
Yeah, so it's an option dep, it will fallback to lodash, other idea for clone performance?— On Fri, Aug 29, 2014 at 8:36 PM, Sindre Sorhus notifications@github.com
|
@sindresorhus So it's outputting the gyp error even though it is listed as an optionalDependency? :( |
I like pure javascript too, we should find whether it's slow exactly and why? |
@popomore Just an FYI the history PR and this PR conflicted, history (an array) was not being deep cloned unless specifically told to - this is a special case like stat that always needs to be deep. I patched this already (0.4.1). I'm okay with going pure JS, I wish native deps weren't such a hassle because the v8 clone is an order of magnitude faster. Is there anything faster than JS? |
@contra ok, that's my fault. |