https://bugzilla.wikimedia.org/show_bug.cgi?id=16852


Aryeh Gregor <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]
                   |                            |m




--- Comment #2 from Aryeh Gregor <[email protected]>  2009-01-14 
14:36:49 UTC ---
+               $lengthOfPadding = mb_strlen( $padding );               
+               if ( $lengthOfPadding == 0 ) return $string;
+               
+               #the remaining length to add counts down to 0 as padding is
added
+               $length = min( $length, 500 ) - mb_strlen( $string );
+               $finalPadding = ''; # $finalPadding is just $padding repeated
enough times so that strlen( $string ) + strlen ( $finalPadding ) == $length
+               while ( $length > 0 ) {
+                       $finalPadding .= mb_substr( $padding, 0, $length );
+                       $length -= $lengthOfPadding;
+               }

This seems pretty elaborate.  Why don't you just do:

                $char = mb_substr( $padding, 0, 1 );
                if ( strlen( $padding ) == 0 ) return $string;
                $length = min( $length, 500 ) - mb_strlen( $string );
                $finalPadding = str_repeat( $char, $length );

I don't understand a lot of what you've written.  Like:

+               $lengthOfPadding = mb_strlen( $padding );               

Why do you care?  You're only padding with the first character anyway, aren't
you?

+                       $finalPadding .= mb_substr( $padding, 0, $length );

Isn't $length usually going to be *longer* than $padding?  And again, why do
you care about more than the first character?  Current code only uses the first
character of the padding and simply discards the rest -- if you're changing
that (other than by using only the first *Unicode* character), you should say
so, and say why.  You should especially address the question of what's expected
to happen if $length isn't a multiple of $lengthOfPadding.


-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to