maybe improve memory footprint

This commit is contained in:
Matthias Wirth
2021-04-25 23:39:08 +02:00
parent 15ab210ee8
commit d478ecb3dc
2 changed files with 26 additions and 24 deletions

View File

@@ -1,6 +1,7 @@
"use strict";
function PlaneObject(icao) {
icao = `${icao}`;
Planes[icao] = this;
PlanesOrdered.push(this);
@@ -1289,7 +1290,7 @@ PlaneObject.prototype.updateData = function(now, last, data, init) {
}
// don't expire callsigns
if (flight != null) {
this.flight = flight;
this.flight = `${flight}`;
}
if (this.flight && this.flight.trim()) {
this.name = this.flight.trim();
@@ -1373,7 +1374,7 @@ PlaneObject.prototype.updateData = function(now, last, data, init) {
this.geom_rate = data.geom_rate;
this.rc = data.rc;
if (!replay || data.squawk != null)
this.squawk = data.squawk;
this.squawk = `${data.squawk}`;
this.wd = data.wd;
this.ws = data.ws;
this.oat = data.oat;
@@ -1386,7 +1387,7 @@ PlaneObject.prototype.updateData = function(now, last, data, init) {
this.version = data.version;
}
if (data.category != null) {
this.category = data.category;
this.category = `${data.category}`;
}
if (data.true_heading != null)
@@ -2048,16 +2049,16 @@ PlaneObject.prototype.getAircraftData = function() {
// format [r:0, t:1, f:2]
if (data[0]) {
this.registration = data[0];
this.registration = `${data[0]}`;
}
if (data[1]) {
this.icaoType = data[1];
this.icaoType = `${data[1]}`;
this.setTypeData();
}
if (data[3]) {
this.typeLong = data[3];
this.typeLong = `${data[3]}`;
}
if (data[2]) {
@@ -2179,7 +2180,7 @@ PlaneObject.prototype.updateTraceData = function(state, _now) {
}
if (data.flight != null) {
this.flight = data.flight;
this.flight = `${data.flight}`;
}
if (this.flight && this.flight.trim()) {
this.name = this.flight.trim();
@@ -2189,7 +2190,7 @@ PlaneObject.prototype.updateTraceData = function(state, _now) {
this.name = '_' + this.icao.toUpperCase();
}
this.addrtype = data.type;
this.addrtype = `${data.type}`;
this.alt_geom = data.alt_geom;
this.ias = data.ias;
@@ -2212,7 +2213,7 @@ PlaneObject.prototype.updateTraceData = function(state, _now) {
this.baro_rate = data.baro_rate;
this.geom_rate = data.geom_rate;
this.rc = data.rc;
this.squawk = data.squawk;
this.squawk = `${data.squawk}`;
this.wd = data.wd;
this.ws = data.ws;
@@ -2223,7 +2224,7 @@ PlaneObject.prototype.updateTraceData = function(state, _now) {
this.version = data.version;
if (data.category != null) {
this.category = data.category;
this.category = `${data.category}`;
}
if (data.nav_altitude_fms != null) {
@@ -2481,9 +2482,9 @@ PlaneObject.prototype.setTypeData = function() {
let typeData = _aircraft_type_cache[typeDesignator];
if (typeData.desc != null && typeData.desc.length == 3)
this.typeDescription = typeData.desc;
this.typeDescription = `${typeData.desc}`;
if (typeData.wtc != null)
this.wtc = typeData.wtc;
this.wtc = `${typeData.wtc}`;
};
PlaneObject.prototype.checkForDB = function(t) {
@@ -2495,14 +2496,14 @@ PlaneObject.prototype.checkForDB = function(t) {
return;
}
if (t.desc) this.typeLong = t.desc;
if (t.r) this.registration = t.r;
if (t.desc) this.typeLong = `${t.desc}`;
if (t.r) this.registration = `${t.r}`;
if (t.ownOp) this.ownOp = t.ownOp;
if (t.year) this.year = t.year;
if (t.ownOp) this.ownOp = `${t.ownOp}`;
if (t.year) this.year = `${t.year}`;
if (t.t) {
this.icaoType = t.t;
this.icaoType = `${t.t}`;
this.setTypeData();
}
if (t.dbFlags) {

View File

@@ -359,16 +359,17 @@ function fetchData(options) {
//console.log(ac_url[i]);
let req;
if (binCraft) {
let xhrOverride = new XMLHttpRequest();
xhrOverride.responseType = 'arraybuffer';
req = $.ajax({
url: ac_url[i], method: 'GET',
xhr: function() { return xhrOverride; },
url: `${ac_url[i]}`, method: 'GET',
xhr: function() {
let xhrOverride = new XMLHttpRequest();
xhrOverride.responseType = 'arraybuffer';
return xhrOverride; },
timeout: 5000,
urlIndex: i,
});
} else {
req = $.ajax({ url: ac_url[i], dataType: 'json', urlIndex: i });
req = $.ajax({ url: `${ac_url[i]}`, dataType: 'json', urlIndex: i });
}
FetchPending.push(req);
@@ -2217,7 +2218,7 @@ function refreshPhoto(selected) {
//console.log(ts/1000 + 'sending psAPI request');
selected.psAPIresponseTS = ts;
let req = $.ajax({
url: 'https://api.planespotters.net/pub/photos/' + urlTail,
url: 'https://api.planespotters.net/pub/photos/' + `${urlTail}`,
dataType: 'json',
plane: selected,
});
@@ -4542,7 +4543,7 @@ function findPlanes(query, byIcao, byCallsign, byReg, byType) {
cache: true,
timeout: 10000,
dataType : 'json',
upper: upper,
upper: `${upper}`,
});
req.done(function(data) {
regCache = data;