Page 1 of 1

Anything better than these 2 ReplaceList?

Posted: 05 Sep 2014 20:39
by klownboy
Hi guys, more for a learning experience and possibly code speed-up as a secondary benefit, I was curious if there might be a better way to handle these two lines of code using "replacelist". I've been reading in other threads where replace has been sped up but replacelist isn't as fast as RegExReplace at least for dealing huge list (which is not the case here). In these 2 lines below, the first is using the thumbnail size selected "$T_size_sel" and relating it to the 5 different thumbnail sizes and getting the corresponding "view" cid (e.g., 308) which will be variable "$thumb_cid". The second line is using an "if" condition along with another "replacelist" simply obtaining the current view and relating it to the different views to obtain the proper corresponding cid, to get into that view (only) if not already. The end result is to get into the "view" based on the selected thumbnail size. I've been studying examples of using regexreplace both here and on other sites, but I'm having no luck. It works fine, but I was wondering if there might be a streamlined or RegExReplace method ?

Code: Select all

    $thumb_cid = replacelist($T_size_sel, "$T_sm|$T_med|$T_lg|48x48|64x64", "306|307|308|313|314","|");
    if(replacelist(get("View"), "4|5|6|8|9", "306|307|308|313|314","|") != $thumb_cid) {#$thumb_cid;}
Thanks,
Ken

Re: Anything better than these 2 ReplaceList?

Posted: 05 Sep 2014 20:56
by highend
So "$T_size_sel" just contains something like 128x128 and the whole process is not inside a loop?
Use replacelist :)

regexmatches / regexreplace come into play when you want to avoid loops or have to grep / replace things
in _large_ variables...

Re: Anything better than these 2 ReplaceList?

Posted: 05 Sep 2014 21:23
by klownboy
Hi highend, I was thinking "replacelist" as I did, was probably fine for this application since we are only talking about 5 different thumbnail size possibilities. Yes, like "240x180". It is in a loop, actually 2 foreach loops one for each path (current folder and all its subs) and a second foreach for the thumbnail sizes selected which there would be anywhere from 1 to 5 total thumb sizes a user could select - which obviously isn't that many. Thanks.