Re: Could this be faster?

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Thu, 15 Dec 2005 20:14:40 -0800, "C Bouzy" <guest at RapidEuphoria.com>
said:
> I added lower() to the following:
> }}}
<eucode> 
> if find(get_file_ext(lower(longname)),{"aac","mp4", "mp3","mp2", "mp1",
> "ogg", "wav"}) then
> </eucode>
{{{

> 
> Without the lower() some files will be skipped do to the fact the 
> file extension is not the same case.

This should be handled by get_file_ext:
if not equal(get_file_ext("a.AAC"),"aac") then ?9/0 end if
if not equal(get_file_ext("a.Mp4"),"mp4") then ?9/0 end if
if not equal(get_file_ext("a.MP4"),"mp4") then ?9/0 end if
if not equal(get_file_ext("a.ogg"),"ogg") then ?9/0 end if
if not equal(get_file_ext("a.ogG"),"ogg") then ?9/0 end if
if not equal(get_file_ext("a.Wav"),"wav") then ?9/0 end if
if not equal(get_file_ext("a.WAV"),"wav") then ?9/0 end if

The above works fine here. Did you change get_file_ext?

Regards,
Pete
PS Since I was looking at it, I spotted an unnecessary memory alloc.
This should work exactly the same but be a fraction faster:
function get_file_ext(sequence filename)
integer c
sequence res
    for i=length(filename) to 1 by -1 do
        c = filename[i]
        if c = '.' then
            res = filename[i+1..length(filename)]
            for j=1 to length(res) do
                c = res[j]
                if c>='A' and c<='Z' then
                    res[j] = c+32
                end if
            end for
            return res
        end if
    end for
    return ""
end function

PPS JL is right: the extension set should really be a parameter or
similar.
-- 
  
  petelomax at fastmail.fm

-- 
http://www.fastmail.fm - Access all of your messages and folders
                          wherever you are

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu