use .fill to initialise Arrays

feature-extract-files
Thomas Grainger 2017-04-13 18:43:38 +01:00
parent d41d56e670
commit 5b03a84be8
No known key found for this signature in database
GPG Key ID: 995EA0A029283160
3 changed files with 3 additions and 14 deletions

View File

@ -88,17 +88,12 @@ const Entropy = {
runFreqDistrib: function (input, args) {
if (!input.length) return "No data";
let distrib = new Array(256),
let distrib = new Array(256).fill(0),
percentages = new Array(256),
len = input.length,
showZeroes = args[0],
i;
// Initialise distrib to 0
for (i = 0; i < 256; i++) {
distrib[i] = 0;
}
// Count bytes
for (i = 0; i < len; i++) {
distrib[input[i]]++;

View File

@ -713,13 +713,9 @@ const IP = {
ip2 = IP._strToIpv6(range[14]);
let t = "",
total = new Array(128),
total = new Array(128).fill(),
i;
// Initialise total array to "0"
for (i = 0; i < 128; i++)
total[i] = "0";
for (i = 0; i < 8; i++) {
t = (ip2[i] - ip1[i]).toString(2);
if (t !== "0") {

View File

@ -397,9 +397,7 @@ const StrUtils = {
}
// Initialise output strings
for (s = 0; s < samples.length; s++) {
outputs[s] = "";
}
outputs.fill("", 0, samples.length);
// Loop through each character in the first sample
for (i = 0; i < samples[0].length; i++) {