[REBOL] Re: comments for beginner ugly code ;-)
From: antonr::lexicon::net at: 15-Mar-2005 0:33
Hi Janeks,
It doesn't look so much like beginner code. :)
But I have one thing to point out. Look at this
console session:
f: func [var][rez: [] append rez var rez]
f 2
;== [2]
f 3
;== [2 3]
f 7
;== [2 3 7]
print mold :f
;func [var][rez: [2 3 7] append rez var rez]
You can see this potential problem in procArtFile.
Should do a COPY:
rez: copy []
And while we are looking at procArtFile, here are some
optimizations:
next next next artText ==> skip artText 3 ==> at artText 4
repend contText either 0 < length? artline [rejoin [artLine " "]][<br>]
There are lots of places in the code where you can optimize
in the above way. All those REPEND RESULT are repetitive and it's
usually more convenient to put everything to be repended into a
block and repend that just once, eg:
repend result [
blah
blah
blah
]
In getMenuLinks in notice you are converting to a string (using FORM),
then back to a file (using to-file):
to-file join form underDir join fileName2 form chapter-info
JOIN will keep the type of its first argument, so as underDir is
already a file!, there is no need to convert it backwards and forwards.
This should be just as good:
join underDir [fileName2 chapter-info]
You should also be able to do this:
underDir/:fileName2/:chapter-info
but we found a bug with that with certain filenames (like 1.s3m)
recently so I recommend the first way for stability at the moment.
(pity, as the second way handles "/" so much better.)
Sorry I haven't commented on the overriding aspects of your code
(security etc).
Regards,
Anton.