[BUG] SemVer.compare causes spurious allocations of SemVer objects
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript
- Lĩnh vực
- tooling
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- JavaScript
- Star
- 5.5k
- Fork
- 598
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của npm/node-semver
-
Bug Needs Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
npm/node-semver#908 ·
-
semver:major
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
npm/node-semver#108 · 6 bình luận ·
-
Bug Needs Triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 64/100
npm/node-semver#909 ·
-
Bug Needs Triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
npm/node-semver#906 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
npm/node-semver#904 ·
Tất cả issue của npm/node-semver
Issue tương tự
-
Mend: dependency security vulnerability untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
opensearch-project/security-dashboards-plugin#2543 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[quality] refresh-radar-reports.yml runs on ubuntu-latest while every other job pins ubuntu-24.04Đang mởagent/quality hive/hosted-available-lke648397-260827-5n31 quality testing
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
godotengine/godot-website#1432 ·
-
Add: Mooz RetroĐang mởchannels:add check:passed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 1 ngày