In AB the unit name is colored depending on the status of the flag they're near, so 5 colors (more if you factor in alpha). In WSG units are red at the horde end and blue at the alliance end. In the middle the unit's color changes smoothly from blue to grey to red depending on where they are (see picture).
At the moment these colors are just passed directly to SetTextColor(). I've done a solution where colors are stored in a weak table and are collected when Grid is finished with them (lifted wholesale from Programming in Lua 17.1). This would create a maximum of one new table per OnUpdate (my addon processes one unit per OnUpdate). The alternative would be to round the color numbers to the nearest 0.05 or whatever, which would produce fewer discrete colors and tables, and fewer update events for Grid. I'm not sure if this is necessary though.