tag:blogger.com,1999:blog-34454975.post7670082694154278373..comments2023-06-28T16:58:41.189+02:00Comments on Web Reflection: NWMatcher - A Quick LookAndrea Giammarchihttp://www.blogger.com/profile/16277820774810688474noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-34454975.post-84218916812729633882009-10-16T14:29:18.953+02:002009-10-16T14:29:18.953+02:00David,
your suggestions are both correct, but the ...David,<br />your suggestions are both correct, but the code have changed in my local development branch...<br /><br />I am lazily committing all the patches collected until now thanks to users suggestions/feedbacks.<br /><br />In current work, I have changed that "for loop" in a "while loop" (419), while in the other part you suggested (1043) the byTags() have disappeared from the current code (was too ugly) but will probably be re-introduced later (rewritten).<br /><br />Thank you for your interest, be aware that I recently added "callback" functionality to NWMatcher and I believe that to be a really and useful new approach.<br /><br />Examples:<br /><br />NW.Dom.select("table > tr td", document, [ ], function(element) { element.style.border = '1px solid black'; });<br /><br />NW.Dom.select("div", document, [ ], Element.extend);<br /><br />Regards,<br /><br />DiegoDiego Perinihttp://www.iport.itnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-14569251769110728662009-10-13T23:34:52.017+02:002009-10-13T23:34:52.017+02:00I've always wondered why selector engines don&...I've always wondered why selector engines don't usually cache functions...great job!<br /><br />@Diego<br />Since its all about speed why not cache "parts.length" in compileGroup (line 419) before iterating?<br /><br />Oh, "i++" on line 1043 should probably be "++i". Its faster and since you are not using the value of "i" before incrementing there is no reason to return it...right?. Or do you know something I don't?<br /><br />I look forward to seeing more of your work.Unknownhttps://www.blogger.com/profile/02986658680984438093noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-18057357153232985422009-10-06T17:09:09.691+02:002009-10-06T17:09:09.691+02:00Hi Diego, about match and cache I meant the pre-co...Hi Diego, about match and cache I meant the pre-compiled lambdas. I think should be wort it, specially with new memory tools, keep a session under control. Maybe there could be a timer every 5 minute able to empty the internal object with cached selectors related lambdas.<br /><br />What do you think? Simple and easy to implement, and it won't change performances, while it will preserve memory usage during long sessions.<br /><br />Thank you for the good job, I'll stay tuned.<br /><br />RegardsAndrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-19037605719687409302009-10-06T16:49:04.378+02:002009-10-06T16:49:04.378+02:00Andrea,
thank you for the nice post, I am currentl...Andrea,<br />thank you for the nice post, I am currently changing the "new Snapshot()" stuff as for your good suggestions (saving memory).<br /><br />The "slice()" feature testing has to remain the way it is since a bug in older Opera browsers will fold the test you suggest.<br /><br />I am currently rewriting the core iteration/recursion of the select() method to better parse and maybe gain some extra milliseconds.<br /><br />Just some notes...the results caching system is only used in the select() method and can easily be turned off through the setCache(true / false)<br />method I made available there.<br /><br />The match() method only saves the compiled functions for reuse, no caching necessary there.<br /><br />It is also very easy to completely remove the caching system from my code, it is currently used only in Firefox and Opera browsers, the ones currently supporting Mutation Events.<br /><br />DiegoDiego Perinihttp://www.iport.itnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-45756457320766544922009-10-06T03:36:00.639+02:002009-10-06T03:36:00.639+02:00Thanks for the writeup Andrea. A couple of notes: ...Thanks for the writeup Andrea. A couple of notes: He uses a more complete check of the `slice` method because as he points out on line 90 native slice will bug out in at least Opera 9.27 when the nodeList contains an element with the id="length". <br /><br />I think you have a valid point about memory consumption and more tests will have to be done. I would not be against having some kind of API to manage the compiled function cache.<br /><br />Thanx<br />JDDJohn-Davidhttps://www.blogger.com/profile/03119997934889825090noreply@blogger.com