[BUG] SemVer.compare causes spurious allocations of SemVer objects
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- javascript
- 領域
- tooling
調査の方向性
Start with functions/compare.js and classes/semver.js, then reproduce the provided SemVer comparison in Chrome's Memory profiler. Verify that comparison operands are handled without spurious SemVer allocations, while preserving the existing behavior for non-SemVer operands.
索引モデルが issue の本文から書いたものです。
説明
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
https://github.com/npm/node-semver/blob/main/functions/compare.js#L3 always creates a new SemVer objects even if you're careful about making sure you're already using SemVer objects.
It relies on https://github.com/npm/node-semver/blob/main/classes/semver.js#L14 to return the original semver from the constructor (TIL Javascript constructors can have return statements). This may work but is surprising and seems to cause a spurious allocation.
Expected Behavior
https://github.com/npm/node-semver/blob/main/functions/compare.js#L3 conditionally converts it's operands to SemVer objects and doesn't create spurious allocations.
Steps To Reproduce
const a = new SemVer("1.0");
const b = new SemVer("2.0");
// Chrome's Memory profiler will tell you that new SemVer objects we're created in this call.
a.compare(b);
Environment
- npm:
- Node: v16
- OS: Mac Os 12.3.1
- platform: Macbook Pro
- 主要言語
- JavaScript
- スター
- 5.5k
- フォーク
- 598
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
npm/node-semver のほかの issue
-
Bug Needs Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
npm/node-semver#908 ·
-
semver:major
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
npm/node-semver#108 · コメント 6 件 ·
-
Bug Needs Triage
難易度 3/5 1〜2日 初心者へのやさしさ 64/100
npm/node-semver#909 ·
-
Bug Needs Triage
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
npm/node-semver#906 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 76/100
npm/node-semver#904 ·
npm/node-semver の issue をすべて見る
似ている issue
-
新讀者走讀回報,照著一篇文章實際操作オープンdocumentation good first issue help wanted
難易度 1/5 1〜3時間 初心者へのやさしさ 92/100
メンテナーはふだん 1 日以内に返信
-
automated issue report
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
lirantal/discoprint#29 ·
メンテナーはふだん 1 日以内に返信
-
feature-request
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
louislam/uptime-kuma#7914 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Code Cleanup dependencies
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
ProjectSidewalk/SidewalkWebpage#5609 ·
メンテナーはふだん 1 日以内に返信
-
help wanted javascript
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
OWASP/cornucopia#3538 ·
メンテナーはふだん 1 日以内に返信