Micro-optimize 'shades' color list
Summary:
Add a new method in PHUITagView with a micro-optimization which stores
these damn ~12 colors, to avoid ~250 calls of `pht()` from the homepage
feeds, especially if there were many mentioned projects.
So this array is calculated only once per request.
P.S.
A new method was created rather than modifying the existing one, so this
is a minimal change, causing less conflicts on Phorge forks with custom
colors. Also, this new method allows to easily implement future workflows
which do not need a cache, for example, showing a demo page with colors
in each supported language, etc.
Also avoid an unnecessary call of the `idx()` function, where it was
used like a ternary operator. So, we just use that operator (T16134).
This saves resources even more, since the ternary operator is faster,
and since the underlying method may be called 20+ times / request
(at least true in my homepage).
Also do not use the method `getShades()` in the examples page
as micro-optimization: we avoid 12*2 calls to 'ucwords()', just to
obtain the same label available from this new cached method.
Also add a TODO about a duplicated color list (T16240).
Closes T16239
Ref T16134
Test Plan:
Assign the "Orange" color to a normal project: no regressions.
Visit the homepage with many projects in the feed: no regressions.
Visit the example page and see absolutely no changes, especially about 'Shades':
http://phorge.localhost/uiexample/view/PHUITagExample/
Visit the project search page and search by "Orange": no regressions.
http://phorge.localhost/project/
Introduce a silly `phlog('lol')` inside `PHUITagView#getShadeMap()` and enjoy the
new cache: you see the 'lol' in the log only once and not ~20+ times.
Therefore, you are saving planet resources. Greta Thunberg may love Phorge more.
Reviewers: O1 Blessed Committers, mainframe98
Reviewed By: O1 Blessed Committers, mainframe98
Subscribers: tobiaswiese, Matthew, Cigaryno
Maniphest Tasks: T16239, T16134
Differential Revision: https://we.phorge.it/D26292