Skip to content

Commit

Permalink
improved loops in getValuesAtPath method
Browse files Browse the repository at this point in the history
  • Loading branch information
scampi committed Nov 16, 2016
1 parent 6a2bc01 commit 991864c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/ui/public/agg_types/metrics/_get_values_at_path.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ export default function (json, path) {
if (pathIndex >= path.length) {
if (element) {
if (element.constructor === Array) {
for (let i = 0; i < element.length; i++) {
if (element[i]) {
values.push(element[i]);
element.forEach(child => {
if (child) {
values.push(child);
}
}
});
} else {
values.push(element);
}
Expand All @@ -50,9 +50,7 @@ export default function (json, path) {
getValues(element[path[pathIndex]], pathIndex + 1);
}
} else if (element.constructor === Array) {
for (let childi = 0; childi < element.length; childi++) {
getValues(element[childi], pathIndex);
}
element.forEach(child => getValues(child, pathIndex));
}
};

Expand Down

0 comments on commit 991864c

Please sign in to comment.