Skip to content

Commit

Permalink
simplify loop - replace while with for
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Mar 27, 2020
1 parent 0d6d798 commit b3a9a96
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/plots/cartesian/set_convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -734,8 +734,9 @@ module.exports = function setConvert(ax, fullLayout) {
var bndDelta;
// step in ms between rangebreaks
var step;
// tracker to position bounds
var t;

var t0 = r0;
var t1 = r1;

switch(brk.pattern) {
case WEEKDAY_PATTERN:
Expand All @@ -746,7 +747,7 @@ module.exports = function setConvert(ax, fullLayout) {
(b1 - b0)
) * ONEDAY;

t = r0 + b0 * ONEDAY - (
t0 += b0 * ONEDAY - (
r0Date.getUTCDay() * ONEDAY +
r0Date.getUTCHours() * ONEHOUR +
r0Date.getUTCMinutes() * ONEMIN +
Expand All @@ -762,7 +763,7 @@ module.exports = function setConvert(ax, fullLayout) {
(b1 - b0)
) * ONEHOUR;

t = r0 + b0 * ONEHOUR - (
t0 += b0 * ONEHOUR - (
r0Date.getUTCHours() * ONEHOUR +
r0Date.getUTCMinutes() * ONEMIN +
r0Date.getUTCSeconds() * ONESEC +
Expand All @@ -771,13 +772,12 @@ module.exports = function setConvert(ax, fullLayout) {
break;
}

while(t <= r1) {
for(var t = t0; t <= t1; t += step) {
// TODO we need to remove decimal (most often found
// in auto ranges) for this to work correctly,
// should this be Math.floor, Math.ceil or
// Math.round ??
addBreak(Math.floor(t), Math.floor(t + bndDelta));
t += step;
}
} else {
bnds = Lib.simpleMap(brk.bounds, ax.r2l);
Expand Down

0 comments on commit b3a9a96

Please sign in to comment.