mirror of
https://github.com/tenrok/axios.git
synced 2026-06-23 20:40:40 +03:00
perf(http): fix early loop exit; (#7202)
This commit is contained in:
+10
-9
@@ -65,9 +65,9 @@ class Http2Sessions {
|
|||||||
sessionTimeout: 1000
|
sessionTimeout: 1000
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
let authoritySessions;
|
let authoritySessions = this.sessions[authority];
|
||||||
|
|
||||||
if ((authoritySessions = this.sessions[authority])) {
|
if (authoritySessions) {
|
||||||
let len = authoritySessions.length;
|
let len = authoritySessions.length;
|
||||||
|
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
@@ -93,11 +93,12 @@ class Http2Sessions {
|
|||||||
|
|
||||||
while (i--) {
|
while (i--) {
|
||||||
if (entries[i][0] === session) {
|
if (entries[i][0] === session) {
|
||||||
entries.splice(i, 1);
|
|
||||||
if (len === 1) {
|
if (len === 1) {
|
||||||
delete this.sessions[authority];
|
delete this.sessions[authority];
|
||||||
return;
|
} else {
|
||||||
|
entries.splice(i, 1);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -136,12 +137,12 @@ class Http2Sessions {
|
|||||||
|
|
||||||
session.once('close', removeSession);
|
session.once('close', removeSession);
|
||||||
|
|
||||||
let entries = this.sessions[authority], entry = [
|
let entry = [
|
||||||
session,
|
session,
|
||||||
options
|
options
|
||||||
];
|
];
|
||||||
|
|
||||||
entries ? this.sessions[authority].push(entry) : authoritySessions = this.sessions[authority] = [entry];
|
authoritySessions ? authoritySessions.push(entry) : authoritySessions = this.sessions[authority] = [entry];
|
||||||
|
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user