-
Notifications
You must be signed in to change notification settings - Fork 140
(perf): minor optimization on attributes extraction #247
Conversation
99a873a
to
51c5bff
Compare
Codecov Report
@@ Coverage Diff @@
## master #247 +/- ##
==========================================
+ Coverage 99.06% 99.53% +0.46%
==========================================
Files 16 16
Lines 642 643 +1
Branches 117 118 +1
==========================================
+ Hits 636 640 +4
+ Misses 6 3 -3
Continue to review full report at Codecov.
|
lib/fragment.js
Outdated
@@ -24,12 +31,17 @@ const getAttributes = (tag, context) => { | |||
Object.assign(attributes, fragmentCtxt); | |||
} | |||
|
|||
return Object.assign({}, attributes, { | |||
url: attributes.src, | |||
const { src, async, primary, public: isPublic, timeout } = attributes; |
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.
why public: isPublic
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.
reserved keyword, changing for async as well.
lib/fragment.js
Outdated
@@ -9,6 +9,13 @@ const zlib = require('zlib'); | |||
const { globalTracer, Tags } = require('opentracing'); | |||
const tracer = globalTracer(); | |||
|
|||
const getValue = value => { |
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.
this function seems misnamed. It's not getting the value, it's doing a kind of extended truthiness-check, isn't it? Maybe better named hasValue
?
👍 |
@mo-gr Need Github PR approval. |
lib/fragment.js
Outdated
Object.assign({}, { id: this.index }, tag.attributes) | ||
); | ||
this.pipeAttributes = pipeAttributes( | ||
Object.assign({}, { id: this.index }, tag.attributes) |
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.
nit: the empty shape is pointless.
lib/fragment.js
Outdated
public: this.attributes.public | ||
public: isPublic, | ||
async: isAsync, | ||
id, |
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 behaviour for id has changed, default arguments only apply to undefined values. Null or empty string will passthrough.
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.
good catch. changing it back
@ruiaraujo Done |
👍 |
1 similar comment
👍 |
small optimisation on fragment attributes computation
Before
After