help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] Re: base64 en/decoding helper


From: Stefan Schmiedl
Subject: Re: [Help-smalltalk] Re: base64 en/decoding helper
Date: Fri, 26 Jun 2009 20:59:30 +0200

I'll reply to a part that I think I understood:

On Fri, 26 Jun 2009 20:39:36 +0200
Joachim Jaeckel <address@hidden> wrote:

>       pads := 0.
>       i := 1.
> 
>       [i <= aString size] whileTrue: [
>           j := i +2.
>           (j > aString size) ifTrue: [j := aString size].
>           tripple := aString copyFrom: i to: j.
> 
>           (tripple size < 3) ifTrue: [
>               pads := 3 - tripple size.
>               1 to: pads do: [ :n |
>                   tripple growBy: 1.
>                   tripple at: (tripple size) put: (0 asCharacter).
>               ]
>           ].

Some quick reflex actions on the above part:

If the string size does not change, put it into a temporary variable.

j already shows if you got three characters, no need to ask tripple
(triplet?) for it's size.

iterate over "aString , '\0\0\0'", you'll get your padding at the end
for free without extra checks

gotta go now,
s.

You're repeatedly grabbing triplets from the string and are looking
every time if you really got three characters, right?

-- 
Stefan Schmiedl
EDV-Beratung Schmiedl, Berghangstr. 5, D-93413 Cham
im Büro: 09971 9966 989, am Handy: 0160 9981 6278




reply via email to

[Prev in Thread] Current Thread [Next in Thread]