Hi, John, I'd have some similar remarks too.
Recently I've updated the patch mentioned here:
http://dev.jquery.com/ticket/3586
and spotted a couple of minor things in filter.ATTR :
(" " + value + " ").indexOf(check) >= 0 :
could be
(" " + value + " ").indexOf( " " + check + " ") >= 0 :
so the following would be unnecessary in preFilter.ATTR:
if ( match[2] === "~=" ) {
match[4] = " " + match[4] + " ";
}
---
!match[4] ?
could be just `check` as it's defined before:
check = match[4];
---
And something that might be worth at least creating a ticket:
elem[ match[1] ] || elem.getAttribute( match[1] )
var el=$('div')[0];
el.foo=0; // or el.foo=false;
el['foo'] || el.getAttribute('foo');
>> null
So, if someone wants to use selectors like [foo=0] or [foo=false] then
it won't work if they directly set the property on an element, but by
using .attr() it works fine:
var $el=$('div').eq(0);
$el.attr('foo', 0);
$el[0]['foo'] || $el[0].getAttribute('foo');
>> "0"
On Feb 1, 3:53 pm, John Resig <[email protected]> wrote:
> Is there any appreciable speed-up to caching RegExp that are that
> small? I wasn't able to find any when I looked.
>
> --John
>
> On Sun, Feb 1, 2009 at 7:58 AM, Diego Perini <[email protected]> wrote:
>
> > I did have a quick look through the code and see that most of the
> > (small) regular expressions are not cached and referenced but defined
> > in-line in the conditionals/replacements.
>
> > For example these are repeatedly used in various place:
>
> > /\s+/
> > /\\/g
> > /\?/
>
> > I believe there are improvements in both speed and readability of code
> > by caching them compiled.
>
> > Is there some reason I don't know in not defining some constants like
> > TRIM, SQUEEZE, ESCAPE etc... ?
>
> > Diego
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---