Skip to content

Commit

Permalink
Better variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
kunalspathak committed Nov 11, 2021
1 parent 6885d97 commit c0d5dfb
Showing 1 changed file with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -417,45 +417,40 @@ private void Get3DMoments(MemoryAllocator allocator)

for (int r = 1; r < IndexCount; r++)
{
volumeSpan.Clear();
#if ALTERNATE
int ind1_r = (r << ((IndexBits * 2) + IndexAlphaBits)) +
// Currently, RyuJIT hoists the invariants of multi-level nested loop only to the
// immediate outer loop. See https://github.com/dotnet/runtime/issues/61420
// To ensure the calculation doesn't happen repeatedly, hoist some of the calculations
// in the form of ind1* manually.
int ind1R = (r << ((IndexBits * 2) + IndexAlphaBits)) +
(r << (IndexBits + IndexAlphaBits + 1)) +
(r << (IndexBits * 2)) +
(r << (IndexBits + 1)) +
r;
#endif

volumeSpan.Clear();

for (int g = 1; g < IndexCount; g++)
{
areaSpan.Clear();

#if ALTERNATE
int ind1_g = ind1_r +
int ind1G = ind1R +
(g << (IndexBits + IndexAlphaBits)) +
(g << IndexBits) +
g;

int r_g = r + g;
#endif

areaSpan.Clear();

for (int b = 1; b < IndexCount; b++)
{
#if ALTERNATE
int ind1_b = ind1_g +
int ind1B = ind1G +
((r_g + b) << IndexAlphaBits) +
b;
#endif

Moment line = default;

for (int a = 1; a < IndexAlphaCount; a++)
{
#if ALTERNATE
int ind1 = ind1_b + a;
#else
int ind1 = GetPaletteIndex(r, g, b, a);
#endif
int ind1 = ind1B + a;

line += momentSpan[ind1];

areaSpan[a] += line;
Expand Down

0 comments on commit c0d5dfb

Please sign in to comment.