Skip to content

Commit

Permalink
Merge branch 'graingert-use-array-fill'
Browse files Browse the repository at this point in the history
  • Loading branch information
n1474335 committed May 5, 2017
2 parents d41d56e + 508a371 commit 61d8d44
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
7 changes: 1 addition & 6 deletions src/core/operations/Entropy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]]++;
Expand Down
6 changes: 1 addition & 5 deletions src/core/operations/IP.js
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
6 changes: 2 additions & 4 deletions src/core/operations/StrUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ const StrUtils = {
runOffsetChecker: function(input, args) {
let sampleDelim = args[0],
samples = input.split(sampleDelim),
outputs = [],
outputs = new Array(samples.length),
i = 0,
s = 0,
match = false,
Expand All @@ -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++) {
Expand Down

0 comments on commit 61d8d44

Please sign in to comment.