JS function works great in FF and Safari, but takes a VERY long time in IE9
<p>Can you see any reason it would work fine in FF and Safari, but when run in IE9 it completely craps out? It takes forever and almost hangs the browser. Thanks!</p>

<p>This is a function that refreshes a list after a keypress. The function clears the list, and then does a linear search through the globally defined array and adds the matches back to the list.</p>

<pre><code>function handleKeyUp()
{
    var selectObj, textObj, componentListLength;
    var i, searchPattern, numShown;

    // Set references to the form elements
    selectObj = document.form1.componentselect;
    textObj = document.form1.componentinput;

    // Remember the function list length for loop speedup
    componentListLength = componentlist.length;

    // Set the search pattern depending
    if(document.form1.componentradio[0].checked == true)
    {
        searchPattern = "^"+textObj.value;
    }
    else
    {
        searchPattern = textObj.value;
    }

    // Create a regular expression
    re = new RegExp(searchPattern,"gi");
    // Clear the options list
    selectObj.length = 0;

    // Loop through the array and re-add matching options
    numShown = 0;
    for(i = 0; i &lt; componentListLength; i++)
    {
        if(componentlist[i].search(re) != -1)
        {
            selectObj[numShown] = new Option(componentlist[i],"");
            numShown++;
        }
    }
}
</code></pre>
