Template talk:Strlen short

This is the talk-page for: Template:Strlen short.

Created
The quick utility Template:Strlen_short was created on 28 December 2010 by long-term user Wikid77 (me) to count string lengths using minimal expansion depth (3 total levels, 2 levels internally), compared to Template:Str_len needing 9 or 13 or more levels to get string lengths of 1-9 or 61 or more characters. The template was created in one edit, but by testing operation in dozens of edit-preview changes, before saving the one edit. -Wikid77 21:57, 27 January 2011 (UTC)

Strlen_short nests 3 levels when str_len uses 13
27-Jan-2011: Expansion depth tests during 2010, of the nesting of Template:Str_len, show over the years it has used 9 expansion levels to count string lengths 1-9, used 10 levels for an 11-character string, but used 13 if-else expansion levels to find the length of a URL of 61 characters. Str_len always uses 4 or more calls to {padleft}, and can nest up to 18 levels for long strings. By using other algorithms, the expansion levels can be reduced. For example, Template:Strlen_short simply checks against a simple, prioritized linear search, never increasing beyond 3 levels of expansion depth nesting, for strings of 0-50 characters. For string lengths of 5,6,7 or 4, Strlen_short uses at most 4 calls to {padleft}, but it could be reduced to just 1 call to {padleft} for the most common length (assumed 5). Strlen_short can also be subst'd, as in {&#123;subst:strlen_short|ABCDEF}} storing just the digit "6". -Wikid77 21:57, 27 January 2011 (UTC)