[BUG] SemVer.compare causes spurious allocations of SemVer objects
I maintainer di solito rispondono entro 4 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- javascript
- Ambito
- tooling
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- JavaScript
- Stelle
- 5.5k
- Fork
- 614
- Merge medio
- 4g 23h
- PR unite (30g)
- 4
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di npm/node-semver
-
[BUG] new Range(comparator).test() throws TypeError for a prerelease versionForse già presa @00200200 l’ha presa 22 giorni fa. ApertaBug Needs Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
npm/node-semver#908 ·
I maintainer di solito rispondono entro 4 giorni
-
semver:major
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
npm/node-semver#108 · 6 commenti ·
I maintainer di solito rispondono entro 4 giorni
-
[BUG] intersects() still returns true for an empty range against "*" (follow-up to #521)Forse già presa @json-open-source l’ha presa 19 giorni fa. ApertaBug Needs Triage
Difficoltà 3/5 1-2 giorni Idoneità per principianti 64/100
npm/node-semver#909 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni
-
[BUG] `* || 1.2.3-alpha` won't match `1.2.3-alpha` (when includePrerelease = false)Forse già presa @x0Lazarus l’ha presa 25 giorni fa. ApertaBug Needs Triage
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
npm/node-semver#906 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni
-
[BUG] gtr and ltr are wrong when a range has two bounds on the same sideForse già presa @Prafyl l’ha presa 30 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 76/100
npm/node-semver#904 ·
I maintainer di solito rispondono entro 4 giorni
Tutte le issue di npm/node-semver
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
docs
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
idean3885/claude-ops-agent#765 ·
I maintainer di solito rispondono entro 1 giorno
-
docs html v6
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Edit: Al Janoubiya TV SDApertacheck:failed feeds:edit
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
iptv-org/database#38385 · 1 commento ·
I maintainer di solito rispondono entro 6 giorni
-
release-followup
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno