Skip to content

Commit

Permalink
WIP: Optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
ptomato committed Apr 27, 2024
1 parent 440a802 commit d988b1a
Show file tree
Hide file tree
Showing 3 changed files with 676 additions and 635 deletions.
10 changes: 3 additions & 7 deletions polyfill/lib/duration.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,7 @@ export class Duration {
ES.DifferenceZonedDateTimeWithRounding(
relativeEpochNs,
targetEpochNs,
plainRelativeTo,
calendarRec,
zonedRelativeTo,
timeZoneRec,
precalculatedPlainDateTime,
ObjectCreate(null),
Expand Down Expand Up @@ -399,7 +397,7 @@ export class Duration {
if (ES.IsCalendarUnit(smallestUnit)) {
throw new RangeError(`a starting point is required for ${smallestUnit}s rounding`);
}
({ days, norm } = ES.RoundDuration(0, 0, 0, days, norm, roundingIncrement, smallestUnit, roundingMode));
({ days, norm } = ES.RoundDuration(days, norm, roundingIncrement, smallestUnit, roundingMode));
({ days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds } = ES.BalanceTimeDuration(
norm.add24HourDays(days),
largestUnit
Expand Down Expand Up @@ -468,9 +466,7 @@ export class Duration {
const { total } = ES.DifferenceZonedDateTimeWithRounding(
relativeEpochNs,
targetEpochNs,
plainRelativeTo,
calendarRec,
zonedRelativeTo,
timeZoneRec,
precalculatedPlainDateTime,
ObjectCreate(null),
Expand Down Expand Up @@ -524,7 +520,7 @@ export class Duration {
throw new RangeError(`a starting point is required for ${unit}s total`);
}
norm = norm.add24HourDays(days);
const { total } = ES.RoundDuration(0, 0, 0, 0, norm, 1, unit, 'trunc');
const { total } = ES.RoundDuration(0, norm, 1, unit, 'trunc');
return total;
}
toString(options = undefined) {
Expand Down Expand Up @@ -563,7 +559,7 @@ export class Duration {
microseconds,
nanoseconds
);
({ norm } = ES.RoundDuration(0, 0, 0, 0, norm, increment, unit, roundingMode));
({ norm } = ES.RoundDuration(0, norm, increment, unit, roundingMode));
let deltaDays;
({
days: deltaDays,
Expand Down
Loading

0 comments on commit d988b1a

Please sign in to comment.