Re: sanity check (coding style)



Christophe Rhodes <csr21@xxxxxxxxx> writes:

(defun digest2string (v)
(with-output-to-string (s)
(loop for x across v
do (format s "~2,'0X" x))))


This is nice, since it uses the string stream to collect the values. If
efficiency is really critical, one could avoid the FORMAT call (which
often tends to be slow) and subsitute a 256 element lookup table:

(defconstant *hex-codes* #("00" "01" ... "FF"))

(defun digest2string (v)
(with-output-to-string (s)
(loop for x across v
do (write-string (aref *hex-codes* x) s))))



--
Thomas A. Russ, USC/Information Sciences Institute

.



Relevant Pages

  • Re: Passive reradiating antenna
    ... loop the efficiency remains the same. ... > ferrite core material. ... For small permeabilities the capture area is much increased. ...
    (rec.radio.amateur.antenna)
  • Re: Efficiency question
    ... I just experimenting with a macro for the ... >don't always just code for efficiency". ... > ' Set this outside the loop as it saves an object ... > ' I've removed the True comparison but the compiler ...
    (microsoft.public.word.vba.general)
  • Efficiency of returning big objects
    ... I had a concern over the efficiency of returning big types, ... Iters: Natural; ... while Clock - Start < 1.0 loop ...
    (comp.lang.ada)
  • Re: Combinatorics question
    ... about efficiency, of course;-) ... your `while xrange' loop by a loop using ... one can do to obtain independent sets in it ... set in the Johnson graph is not known, ...
    (sci.math)
  • Re: String.replace() in practice
    ... When replaceefficiency is not as good as expected, it's replaceimplementation fault, not mine I think. ... once *before* the loop. ... Compiling pattern once before calling replaceAllis not as convenient as using replace, and is not necessarily helpful in all situations. ...
    (comp.lang.java.programmer)