Anything better than these 2 ReplaceList?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
klownboy
Posts: 4462
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Anything better than these 2 ReplaceList?

Post 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

highend
Posts: 14953
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Anything better than these 2 ReplaceList?

Post 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...
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4462
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: Anything better than these 2 ReplaceList?

Post 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.

Post Reply