Skip to content

Commit 40a9104

Browse files
committed
Revert "perf-marks - use global or self or nothing"
This reverts commit 8041780.
1 parent 8041780 commit 40a9104

1 file changed

Lines changed: 7 additions & 15 deletions

File tree

src/vs/base/common/performance.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,22 @@ if (typeof define !== "function" && typeof module === "object" && typeof module.
2222

2323
define([], function () {
2424

25-
let _performanceEntries;
26-
if (typeof global === 'object') {
27-
_performanceEntries = global._performanceEntries = [];
28-
} else if (typeof self === 'object') {
29-
_performanceEntries = self._performanceEntries = [];
30-
} else {
31-
_performanceEntries = [];
32-
}
33-
25+
global._performanceEntries = global._performanceEntries || [];
3426

3527
const _dataLen = 2;
3628
const _timeStamp = typeof console.timeStamp === 'function' ? console.timeStamp.bind(console) : () => { };
3729

3830
function importEntries(entries) {
39-
_performanceEntries.splice(0, 0, ...entries);
31+
global._performanceEntries.splice(0, 0, ...entries);
4032
}
4133

4234
function exportEntries() {
43-
return _performanceEntries.slice(0);
35+
return global._performanceEntries.slice(0);
4436
}
4537

4638
function getEntries() {
4739
const result = [];
48-
const entries = _performanceEntries;
40+
const entries = global._performanceEntries;
4941
for (let i = 0; i < entries.length; i += _dataLen) {
5042
result.push({
5143
name: entries[i],
@@ -56,7 +48,7 @@ define([], function () {
5648
}
5749

5850
function getEntry(name) {
59-
const entries = _performanceEntries;
51+
const entries = global._performanceEntries;
6052
for (let i = 0; i < entries.length; i += _dataLen) {
6153
if (entries[i] === name) {
6254
return {
@@ -68,7 +60,7 @@ define([], function () {
6860
}
6961

7062
function getDuration(from, to) {
71-
const entries = _performanceEntries;
63+
const entries = global._performanceEntries;
7264
let target = to;
7365
let endIndex = 0;
7466
for (let i = entries.length - _dataLen; i >= 0; i -= _dataLen) {
@@ -87,7 +79,7 @@ define([], function () {
8779
}
8880

8981
function mark(name) {
90-
_performanceEntries.push(name, Date.now());
82+
global._performanceEntries.push(name, Date.now());
9183
_timeStamp(name);
9284
}
9385

0 commit comments

Comments
 (0)