<?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>Thu, 09 Feb 2012 10:18:35 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Ian Farrell</title>
		<link>http://blog.stevenlevithan.com/archives/fast-string-multiply/comment-page-1#comment-98127</link>
		<dc:creator>Ian Farrell</dc:creator>
		<pubDate>Tue, 26 Apr 2011 10:36:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/fast-string-multiply#comment-98127</guid>
		<description>Further optimization:

function stringMultiply(s, n, i) {
 for (i = 0, x = Math.log(n) / Math.LN2 &#124; 0, t = s; i++ &lt; x; s += s);
 return n ? s + stringMultiply(t, n - (2 &lt;&lt; x - 1 &#124;&#124; 1)) : &#039;&#039;;
}</description>
		<content:encoded><![CDATA[<p>Further optimization:</p>
<p>function stringMultiply(s, n, i) {<br />
 for (i = 0, x = Math.log(n) / Math.LN2 | 0, t = s; i++ &lt; x; s += s);<br />
 return n ? s + stringMultiply(t, n &#8211; (2 &lt;&lt; x &#8211; 1 || 1)) : &#039;&#039;;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Farrell</title>
		<link>http://blog.stevenlevithan.com/archives/fast-string-multiply/comment-page-1#comment-88843</link>
		<dc:creator>Ian Farrell</dc:creator>
		<pubDate>Mon, 21 Mar 2011 21:04:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/fast-string-multiply#comment-88843</guid>
		<description>Harnessing the magical powers of exponentiation *and* recursion I present you the most powerful string multiplication method ever devised! (To see it&#039;s true power compare to it other functions by multiplying strings by 100 million, etc.)

function stringMultiply3(string, n) {
  var x = Math.floor(Math.log(n)/Math.LN2), temp = string;
  for(var i=0; i &lt; x; i++)
    string += string;
  return (n) ? string + stringMultiply3(temp, n - Math.pow(2, x)) : &#039;&#039;;
}

Huzzah! (Visit my website http://ian0.com/ for more cool JS magic.)</description>
		<content:encoded><![CDATA[<p>Harnessing the magical powers of exponentiation *and* recursion I present you the most powerful string multiplication method ever devised! (To see it&#8217;s true power compare to it other functions by multiplying strings by 100 million, etc.)</p>
<p>function stringMultiply3(string, n) {<br />
  var x = Math.floor(Math.log(n)/Math.LN2), temp = string;<br />
  for(var i=0; i &lt; x; i++)<br />
    string += string;<br />
  return (n) ? string + stringMultiply3(temp, n &#8211; Math.pow(2, x)) : &#8221;;<br />
}</p>
<p>Huzzah! (Visit my website <a href="http://ian0.com/" rel="nofollow">http://ian0.com/</a> for more cool JS magic.)</p>
]]></content:encoded>
	</item>
	<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>
</channel>
</rss>

