From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7844279822ce7c28 X-Google-Attributes: gid103376,public From: tmoran@bix.com Subject: Re: Newbie question : types , representation Date: 1999/08/27 Message-ID: <5oAx3.5359$W5.510061@typhoon-sf.snfc21.pbi.net>#1/1 X-Deja-AN: 517943219 References: <37C621F3.C6C0DC3A@acenet.com.au> X-Complaints-To: abuse@pacbell.net X-Trace: typhoon-sf.snfc21.pbi.net 935776897 207.214.211.230 (Fri, 27 Aug 1999 11:01:37 PDT) Organization: SBC Internet Services NNTP-Posting-Date: Fri, 27 Aug 1999 11:01:37 PDT Newsgroups: comp.lang.ada Date: 1999-08-27T00:00:00+00:00 List-Id: > In base64 decoding , each ASCII character must be translated to 6 'bit'. > 4 characters translate then to 3 bytes. The problem and algorithms are > trivial. In C I could do it within 5 minutes. Given modern RAM sizes, how about the initally mentioned table lookup type Base64 is range 0 .. 63; type Base64_String is array(integer range <>) of Base64; subtype Base64_Quad is Base64_String(1 .. 4); type Byte is range 0 .. 255; type Byte_String is array(integer range <>) of Byte; subtype Byte_Triple is Byte_String(1 .. 3); To_Base64 : array(Byte, Byte, Byte) of Base64_Quad; From_Base64 : array(Base64, Base64, Base64, Base64) of Byte_Triple; -- initialize the arrays once, at start time -- timing test data: Base64_String(1 .. 200); result : Byte_String(1 .. 150); si,di : positive; begin for i in 1 .. 100_000 loop si := 1; di := 1; for j in 1 .. data'length/4 loop result(di .. di+2) := From_Base64(Data(si), Data(si+1), Data(si+2), Data(si+3)); di := di+3; si := si+4; end loop; end loop; On my P200, this sort of thing executes at a rate of about 6 Base64 characters, or 4 Byte's, converted each microsecond. Using a modern fast CPU you would approach being I/O bound.