<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: JavaScript String Multiplication Performance Exploration</title>
	<atom:link href="http://blog.stevenlevithan.com/archives/fast-string-multiply/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.stevenlevithan.com/archives/fast-string-multiply</link>
	<description>A JavaScript and regular expression centric blog</description>
	<lastBuildDate>Tue, 09 Mar 2010 12:48:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Victor</title>
		<link>http://blog.stevenlevithan.com/archives/fast-string-multiply/comment-page-1#comment-41387</link>
		<dc:creator>Victor</dc:creator>
		<pubDate>Thu, 01 Oct 2009 09:26:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/fast-string-multiply#comment-41387</guid>
		<description>Another  &quot;square-and-multiply&quot; algorithm:

String.prototype.times = function(count) {
  count = (count &gt;&gt; 0);
  var t = (count &gt; 1? this.times(count / 2): &#039;&#039;);
  return t + (count % 2? t + this: t);
};
//use &#039;x&#039;.times(1000000)</description>
		<content:encoded><![CDATA[<p>Another  &#8220;square-and-multiply&#8221; algorithm:</p>
<p>String.prototype.times = function(count) {<br />
  count = (count &gt;&gt; 0);<br />
  var t = (count &gt; 1? this.times(count / 2): &#8221;);<br />
  return t + (count % 2? t + this: t);<br />
};<br />
//use &#8216;x&#8217;.times(1000000)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chetpot</title>
		<link>http://blog.stevenlevithan.com/archives/fast-string-multiply/comment-page-1#comment-26572</link>
		<dc:creator>chetpot</dc:creator>
		<pubDate>Sun, 01 Mar 2009 00:44:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/fast-string-multiply#comment-26572</guid>
		<description>here is a little something that I usually use.
since i am a fan of Perl which uses x for multiplying strings 
i named the function x and added it to the string object.


//-- adds a multiplier function to any string object
//-- use: String.x(number)
//-- example: 
//--   var str=&#039;hi&#039;;
//--   str.x(3);
//-- returns: hihihi

String.prototype.x=function(x){
	if(arguments.length==0)return this;
	if(x&lt;=0)return this;
	var out=&#039;&#039;;
	for(i=0;i&lt;x;i++){
		out+=this
	}
	return out;
}


this is useful since you can add it to any other built in string modifier
eg.
string.replace(/hi/,&#039;bye&#039;).x(10)</description>
		<content:encoded><![CDATA[<p>here is a little something that I usually use.<br />
since i am a fan of Perl which uses x for multiplying strings<br />
i named the function x and added it to the string object.</p>
<p>//&#8211; adds a multiplier function to any string object<br />
//&#8211; use: String.x(number)<br />
//&#8211; example:<br />
//&#8211;   var str=&#8217;hi&#8217;;<br />
//&#8211;   str.x(3);<br />
//&#8211; returns: hihihi</p>
<p>String.prototype.x=function(x){<br />
	if(arguments.length==0)return this;<br />
	if(x&lt;=0)return this;<br />
	var out=&#8221;;<br />
	for(i=0;i&lt;x;i++){<br />
		out+=this<br />
	}<br />
	return out;<br />
}</p>
<p>this is useful since you can add it to any other built in string modifier<br />
eg.<br />
string.replace(/hi/,&#8217;bye&#8217;).x(10)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: manga</title>
		<link>http://blog.stevenlevithan.com/archives/fast-string-multiply/comment-page-1#comment-25004</link>
		<dc:creator>manga</dc:creator>
		<pubDate>Sat, 30 Aug 2008 08:33:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/fast-string-multiply#comment-25004</guid>
		<description>i want natural language search that code is very usefull for me.</description>
		<content:encoded><![CDATA[<p>i want natural language search that code is very usefull for me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daghan Dinc</title>
		<link>http://blog.stevenlevithan.com/archives/fast-string-multiply/comment-page-1#comment-15311</link>
		<dc:creator>Daghan Dinc</dc:creator>
		<pubDate>Thu, 28 Feb 2008 11:18:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/fast-string-multiply#comment-15311</guid>
		<description>Ordinary square-and-multiply without use of arrays etc
works better-than-or-equal-to the ones above for ie7 and ff2 (as far as i tested:) )

Thank you all for this great thread

&lt;code&gt;function mulDaghan(str,count){
&#160;&#160;&#160;&#160;if(count==0) return &#039;&#039;;
&#160;&#160;&#160;&#160;var binaryCount = count.toString(2);	
&#160;&#160;&#160;&#160;var numDegree = binaryCount.length;	
&#160;&#160;&#160;&#160;var resultStr=&#039;&#039;;
&#160;&#160;&#160;&#160;for(var i=0; i&lt;numDegree; i++){
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;resultStr+=resultStr; // for both 0 and 1	
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if(binaryCount.charAt(i) == &#039;1&#039;){
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;resultStr+=str;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}
&#160;&#160;&#160;&#160;}
&#160;&#160;&#160;&#160;return resultStr;
}&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Ordinary square-and-multiply without use of arrays etc<br />
works better-than-or-equal-to the ones above for ie7 and ff2 (as far as i tested:) )</p>
<p>Thank you all for this great thread</p>
<p><code>function mulDaghan(str,count){<br />
&nbsp;&nbsp;&nbsp;&nbsp;if(count==0) return &#x27;&#x27;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;var binaryCount = count.toString(2);<br />
&nbsp;&nbsp;&nbsp;&nbsp;var numDegree = binaryCount.length;<br />
&nbsp;&nbsp;&nbsp;&nbsp;var resultStr=&#x27;&#x27;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;for(var i=0; i&lt;numDegree; i++){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;resultStr+=resultStr; // for both 0 and 1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(binaryCount.charAt(i) == '1'){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;resultStr+=str;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;return resultStr;<br />
}</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://blog.stevenlevithan.com/archives/fast-string-multiply/comment-page-1#comment-8920</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Sun, 02 Dec 2007 19:31:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/fast-string-multiply#comment-8920</guid>
		<description>@Sam, yeah, this was mostly just for the fun of it. As for regular expressions, as you can see I&#039;m a big fan. It keeps my blog geared towards a niche audience, but so be it.</description>
		<content:encoded><![CDATA[<p>@Sam, yeah, this was mostly just for the fun of it. As for regular expressions, as you can see I&#8217;m a big fan. It keeps my blog geared towards a niche audience, but so be it.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
