Commit bfec4d1
authored
Avoid double-loop and branching for leap years
This avoids the variable-length array issue n #429. The previous
implementation uses 'leap' to:
* Run a full 'nyear' loop to populate whether each year is leap.
* Run a second loop to count the number of days from the array
(the branch prediction in each iteration will be wrong about
half the time).
Count the number of days directly in one loop. This is slightly more
memory-efficient and should be more computationally efficient too.
Closes #430. See #429.1 parent ae39d2b commit bfec4d1
1 file changed
+7
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
41 | 39 | | |
42 | 40 | | |
43 | 41 | | |
44 | 42 | | |
45 | 43 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | 44 | | |
53 | 45 | | |
54 | 46 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
60 | 54 | | |
61 | 55 | | |
62 | 56 | | |
| |||
0 commit comments