GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — perf_hooks: do not expose SafeMap via Histogram wrapper · nodejs/node@f67b686

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal
    • histogram.js
  • test/parallel
    • test-perf-hooks-histogram.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/histogram.js‎

Copy file name to clipboardExpand all lines: lib/internal/histogram.js
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
'use strict';
22

33
const {
4+
Map,
5+
MapPrototypeClear,
46
MapPrototypeEntries,
57
NumberIsNaN,
68
NumberMAX_SAFE_INTEGER,
79
ObjectFromEntries,
810
ReflectConstruct,
9-
SafeMap,
1011
Symbol,
1112
} = primordials;
1213

@@ -216,7 +217,7 @@ class Histogram {
216217
get percentiles() {
217218
if (!isHistogram(this))
218219
throw new ERR_INVALID_THIS('Histogram');
219-
this[kMap].clear();
220+
MapPrototypeClear(this[kMap]);
220221
this[kHandle]?.percentiles(this[kMap]);
221222
return this[kMap];
222223
}
@@ -228,7 +229,7 @@ class Histogram {
228229
get percentilesBigInt() {
229230
if (!isHistogram(this))
230231
throw new ERR_INVALID_THIS('Histogram');
231-
this[kMap].clear();
232+
MapPrototypeClear(this[kMap]);
232233
this[kHandle]?.percentilesBigInt(this[kMap]);
233234
return this[kMap];
234235
}
@@ -331,7 +332,7 @@ function ClonedHistogram(handle) {
331332
function() {
332333
markTransferMode(this, true, false);
333334
this[kHandle] = handle;
334-
this[kMap] = new SafeMap();
335+
this[kMap] = new Map();
335336
}, [], Histogram);
336337
}
337338

@@ -342,7 +343,7 @@ function ClonedRecordableHistogram(handle) {
342343

343344
markTransferMode(histogram, true, false);
344345
histogram[kRecordable] = true;
345-
histogram[kMap] = new SafeMap();
346+
histogram[kMap] = new Map();
346347
histogram[kHandle] = handle;
347348
histogram.constructor = RecordableHistogram;
348349

Collapse file

‎test/parallel/test-perf-hooks-histogram.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-perf-hooks-histogram.js
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const common = require('../common');
44

55
const {
6+
deepStrictEqual,
67
ok,
78
strictEqual,
89
throws,
@@ -58,6 +59,10 @@ const { inspect } = require('util');
5859
strictEqual(h.percentileBigInt(1), 1n);
5960
strictEqual(h.percentileBigInt(100), 1n);
6061

62+
deepStrictEqual(h.percentiles, new Map([[0, 1], [100, 1]]));
63+
64+
deepStrictEqual(h.percentilesBigInt, new Map([[0, 1n], [100, 1n]]));
65+
6166
const mc = new MessageChannel();
6267
mc.port1.onmessage = common.mustCall(({ data }) => {
6368
strictEqual(h.min, 1);

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.