<?xml version="1.0" encoding="UTF-8"?>
<post>
  <body>&lt;blockquote&gt;Really? I always though indexOf was really slow. You wouldn't have any data to back that up by any change? I'm also curious, how would Regexp compare.&lt;/blockquote&gt;

Actually... indexOf is much faster than RegExp. Here are my tests...

Function 1 is this:
&lt;code&gt;'big house'.indexOf('house')!=-1;&lt;/code&gt;
Function 2 is this:
&lt;code&gt;/house/.test(/big house/);&lt;/code&gt;

The results are:
&lt;blockquote&gt;Function 1 is 1,797 ms (5.61x) faster than Function 2
Used 1,000,000 loops twice over 2.577 seconds total
Function 1 time: 390 ms
Function 2 time: 2,187 ms&lt;/blockquote&gt;

As you can see, indexOf was 5.61 times faster than RegExp.

You can test this or anything for yourself in my &lt;em&gt;Measure Functions' Execution Times&lt;/em&gt; script.

I've found that comparing searching innerHTML and textContent, that searching the textContent is 27x faster. You can test for yourself in my script using document.body.</body>
  <body-html>&lt;p&gt;&lt;blockquote&gt;Really? I always though indexOf was really slow. You wouldn't have any data to back that up by any change? I'm also curious, how would Regexp compare.&lt;/blockquote&gt;&lt;/p&gt;

&lt;p&gt;Actually... indexOf is much faster than RegExp. Here are my tests...&lt;/p&gt;

&lt;p&gt;Function 1 is this:
&lt;br /&gt;&lt;code&gt;'big house'.indexOf('house')!=-1;&lt;/code&gt;
&lt;br /&gt;Function 2 is this:
&lt;br /&gt;&lt;code&gt;/house/.test(/big house/);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The results are:
&lt;br /&gt;&lt;blockquote&gt;Function 1 is 1,797 ms (5.61x) faster than Function 2
&lt;br /&gt;Used 1,000,000 loops twice over 2.577 seconds total
&lt;br /&gt;Function 1 time: 390 ms
&lt;br /&gt;Function 2 time: 2,187 ms&lt;/blockquote&gt;&lt;/p&gt;

&lt;p&gt;As you can see, indexOf was 5.61 times faster than RegExp.&lt;/p&gt;

&lt;p&gt;You can test this or anything for yourself in my &lt;em&gt;Measure Functions' Execution Times&lt;/em&gt; script.&lt;/p&gt;

&lt;p&gt;I've found that comparing searching innerHTML and textContent, that searching the textContent is 27x faster. You can test for yourself in my script using document.body.&lt;/p&gt;</body-html>
  <created-at type="datetime">2008-12-20T20:24:12Z</created-at>
  <forumable-id type="integer">2</forumable-id>
  <forumable-type>Forum</forumable-type>
  <id type="integer">85042</id>
  <topic-id type="integer">18247</topic-id>
  <updated-at type="datetime">2008-12-20T20:49:43Z</updated-at>
  <user-agent nil="true"></user-agent>
  <user-id type="integer">23652</user-id>
</post>
