Skip to content

fix: speedup dayOfWeek routine in date#3033

Open
MaxGraey wants to merge 2 commits into
AssemblyScript:mainfrom
MaxGraey:date-perf
Open

fix: speedup dayOfWeek routine in date#3033
MaxGraey wants to merge 2 commits into
AssemblyScript:mainfrom
MaxGraey:date-perf

Conversation

@MaxGraey

@MaxGraey MaxGraey commented Jul 8, 2026

Copy link
Copy Markdown
Member
floorDiv(year, 400)  ->  floorDiv(floorDiv(year, 100), 4) 

Since arithmetic shift year >> 2 is equal to floorDiv(year, 4):

century = floorDiv(year, 100)
floorDiv(century, 4)  ->  century >> 2

And full simplifcation:

floorDiv(year, 4) - floorDiv(year, 100) + floorDiv(year, 400)

->

(year >> 2) - century + (century >> 2)

Also added couple of tests

  • I've read the contributing guidelines
  • I've added my name and email to the NOTICE file

Comment thread std/assembly/date.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants