<?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: StringMap</title>
	<atom:link href="http://meshula.net/wordpress/?feed=rss2&#038;p=183" rel="self" type="application/rss+xml" />
	<link>http://meshula.net/wordpress/?p=183</link>
	<description>Spaces Between</description>
	<lastBuildDate>Mon, 30 Aug 2010 08:23:36 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: admin</title>
		<link>http://meshula.net/wordpress/?p=183&#038;cpage=1#comment-7379</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Sun, 15 Mar 2009 21:41:08 +0000</pubDate>
		<guid isPermaLink="false">http://meshula.net/wordpress/?p=183#comment-7379</guid>
		<description>In the era Bentley and Sedgewick wrote this code, it was traditional for the programmer to write a recursion to iterate the tree; see the example print-in-order function in the supplied code. The notion of iterators came a bit later, and is perhaps not ideally mapped to this structure. In my own usage of this code, I use it strictly for fast lookup, and write a recursion when I need to iterate over all the items.

Perhaps a reader has a suggestion on how to write a better iterator than the one I knocked together for this tutorial, or better, has a way to update the StringMap for efficient interoperability with the STL?</description>
		<content:encoded><![CDATA[<p>In the era Bentley and Sedgewick wrote this code, it was traditional for the programmer to write a recursion to iterate the tree; see the example print-in-order function in the supplied code. The notion of iterators came a bit later, and is perhaps not ideally mapped to this structure. In my own usage of this code, I use it strictly for fast lookup, and write a recursion when I need to iterate over all the items.</p>
<p>Perhaps a reader has a suggestion on how to write a better iterator than the one I knocked together for this tutorial, or better, has a way to update the StringMap for efficient interoperability with the STL?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gogo</title>
		<link>http://meshula.net/wordpress/?p=183&#038;cpage=1#comment-7284</link>
		<dc:creator>gogo</dc:creator>
		<pubDate>Tue, 03 Mar 2009 14:29:20 +0000</pubDate>
		<guid isPermaLink="false">http://meshula.net/wordpress/?p=183#comment-7284</guid>
		<description>How could be the code to write a StringMap iterator, pls?
Currently you&#039;re just copying the elements to a std::vector which consumes a lot of memory. An iterator could be better.

thx.</description>
		<content:encoded><![CDATA[<p>How could be the code to write a StringMap iterator, pls?<br />
Currently you&#8217;re just copying the elements to a std::vector which consumes a lot of memory. An iterator could be better.</p>
<p>thx.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://meshula.net/wordpress/?p=183&#038;cpage=1#comment-7178</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Mon, 23 Feb 2009 00:03:21 +0000</pubDate>
		<guid isPermaLink="false">http://meshula.net/wordpress/?p=183#comment-7178</guid>
		<description>traceback http://stackoverflow.com/questions/571890?sort=newest</description>
		<content:encoded><![CDATA[<p>traceback <a href="http://stackoverflow.com/questions/571890?sort=newest" rel="nofollow">http://stackoverflow.com/questions/571890?sort=newest</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://meshula.net/wordpress/?p=183&#038;cpage=1#comment-6578</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Sun, 13 Jul 2008 02:26:16 +0000</pubDate>
		<guid isPermaLink="false">http://meshula.net/wordpress/?p=183#comment-6578</guid>
		<description>Ok, I posted new exception safe code, thanks for all the feedback!

I have retimed the code as well, just to be sure.</description>
		<content:encoded><![CDATA[<p>Ok, I posted new exception safe code, thanks for all the feedback!</p>
<p>I have retimed the code as well, just to be sure.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://meshula.net/wordpress/?p=183&#038;cpage=1#comment-6576</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Sat, 12 Jul 2008 22:24:52 +0000</pubDate>
		<guid isPermaLink="false">http://meshula.net/wordpress/?p=183#comment-6576</guid>
		<description>(admin is Nick)

The fix to exception safety is actually pretty simple now that I think about it. We can replace malloc/free with new[] and delete[], since they will throw if the allocation fails. Whether or not the assignment of Data can throw doesn&#039;t matter; one would expect the user to need to deal with a failure of assignment in the map, it&#039;s not the place of the map to deal with it.

I&#039;ve written a new post to help explain some of the characteristics of game code that non-game coders find hard to fathom. I don&#039;t think it&#039;s really fair to say our code is horrible or hacky!

http://meshula.net/wordpress/?p=185

Beauty is in the eye of the beholder, and what seem to some practitioners to be the most hideous code possible, to someone else can be an elegant rose. I must point out that a wood carver would never allow his knives to cut another material, yet for carving wood, his knives are the perfect instrument. Game code by and large is craft informed by engineering.</description>
		<content:encoded><![CDATA[<p>(admin is Nick)</p>
<p>The fix to exception safety is actually pretty simple now that I think about it. We can replace malloc/free with new[] and delete[], since they will throw if the allocation fails. Whether or not the assignment of Data can throw doesn&#8217;t matter; one would expect the user to need to deal with a failure of assignment in the map, it&#8217;s not the place of the map to deal with it.</p>
<p>I&#8217;ve written a new post to help explain some of the characteristics of game code that non-game coders find hard to fathom. I don&#8217;t think it&#8217;s really fair to say our code is horrible or hacky!</p>
<p><a href="http://meshula.net/wordpress/?p=185" rel="nofollow">http://meshula.net/wordpress/?p=185</a></p>
<p>Beauty is in the eye of the beholder, and what seem to some practitioners to be the most hideous code possible, to someone else can be an elegant rose. I must point out that a wood carver would never allow his knives to cut another material, yet for carving wood, his knives are the perfect instrument. Game code by and large is craft informed by engineering.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pseudonym</title>
		<link>http://meshula.net/wordpress/?p=183&#038;cpage=1#comment-6566</link>
		<dc:creator>Pseudonym</dc:creator>
		<pubDate>Fri, 11 Jul 2008 06:48:01 +0000</pubDate>
		<guid isPermaLink="false">http://meshula.net/wordpress/?p=183#comment-6566</guid>
		<description>Thanks, Mike.  Wrapping working code in a class may be ugly, but yeah, it works.

Incidentally, it wasn&#039;t just the upper limit on capacity that concerned me with StringMap.

The exception-safety aspect did concern me.  The fact that Mike claims that it &quot;can’t throw exceptions&quot; just goes to show how subtle exceptions can be, if a good C++ programmer can&#039;t spot situations where it might happen.  There&#039;s the inOrder stuff that manipulates STL containers (which is safe in this case), there&#039;s always the possibility that Data::operator=() might throw (which, again, is safe in this case, but it only takes a small refactor and instantly it&#039;s not).

Dealing with error conditions is the biggie.  Admittedly, it&#039;s the original code&#039;s fault that the return value of malloc() isn&#039;t checked, but still, it&#039;s a fault.

Alexey wrote: &quot;It is common in game programming to use limited containers for performance reasons.&quot;

I don&#039;t think I&#039;ll ever understand game programmers.  They do the most horrible hacks that anyone else in any other area of high-performance computing wouldn&#039;t even begin to consider.

I suspect it&#039;s more often for deadline reasons than performance reasons, but don&#039;t quote me on that.</description>
		<content:encoded><![CDATA[<p>Thanks, Mike.  Wrapping working code in a class may be ugly, but yeah, it works.</p>
<p>Incidentally, it wasn&#8217;t just the upper limit on capacity that concerned me with StringMap.</p>
<p>The exception-safety aspect did concern me.  The fact that Mike claims that it &#8220;can’t throw exceptions&#8221; just goes to show how subtle exceptions can be, if a good C++ programmer can&#8217;t spot situations where it might happen.  There&#8217;s the inOrder stuff that manipulates STL containers (which is safe in this case), there&#8217;s always the possibility that Data::operator=() might throw (which, again, is safe in this case, but it only takes a small refactor and instantly it&#8217;s not).</p>
<p>Dealing with error conditions is the biggie.  Admittedly, it&#8217;s the original code&#8217;s fault that the return value of malloc() isn&#8217;t checked, but still, it&#8217;s a fault.</p>
<p>Alexey wrote: &#8220;It is common in game programming to use limited containers for performance reasons.&#8221;</p>
<p>I don&#8217;t think I&#8217;ll ever understand game programmers.  They do the most horrible hacks that anyone else in any other area of high-performance computing wouldn&#8217;t even begin to consider.</p>
<p>I suspect it&#8217;s more often for deadline reasons than performance reasons, but don&#8217;t quote me on that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://meshula.net/wordpress/?p=183&#038;cpage=1#comment-6528</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Tue, 08 Jul 2008 05:33:40 +0000</pubDate>
		<guid isPermaLink="false">http://meshula.net/wordpress/?p=183#comment-6528</guid>
		<description>Alexey, I can&#039;t get the bufn-- to display properly. I put a space in, it&#039;s ugly but hopefully people will get it.

Here&#039;s the dictionary.txt file I used:

&lt;a href=&quot;http://java.sun.com/docs/books/tutorial/collections/interfaces/examples/dictionary.txt&quot; rel=&quot;nofollow&quot;&gt;http://java.sun.com/docs/books/tutorial/collections/interfaces/examples/dictionary.txt&lt;/a&gt;


Here&#039;s the timing code. I haven&#039;t filled in a gcc version of the cycle timer. I would appreciate your timings with STLPort; I might imagine it to be much faster than the Dinkumware implementation Microsoft ships. Please also mention which compiler and settings you used.

Sorry for the screwball formatting, I need some kind of nice code display plugin...

&lt;code&gt;
	class Cycles
	{
	public:
		Cycles()
		{
			Reset();
		}

		void Reset()
		{
			Sample();
			start = cycles;
		}

#ifdef _MSC_VER
		void Sample()
		{
			int dwLow, dwHigh;
			__asm
			{
				rdtsc
				mov dwLow, eax
				mov dwHigh, edx
			}
			cycles = ((unsigned long long)dwHigh &lt;&lt; 32) &#124;
				(unsigned long long) dwLow; 
		}
#else
		void Sample() { cycles = 0; }
#endif

		unsigned long long Total() const { return cycles - start; }

		unsigned long long start;
		unsigned long long cycles;
	};


	std::vector&lt;std::string&gt; dictionary;
	std::ifstream dict;
	dict.open(&quot;d:\\dictionary.txt&quot;);
	while (!dict.eof())
	{
		char buff[256];
		dict.getline(buff, 256);
		dictionary.push_back(buff);
	}

	Base::Cycles ct;
	// test one, map, insert dictionary, alphabetical order
	{
		// 565M, 3248M in debug
		ct.Reset();
		std::map&lt;std::string, int&gt; mapTest;
		for (size_t i = 0; i &lt; dictionary.size(); ++i)
		{
			mapTest.insert(std::pair&lt;std::string, int&gt;(dictionary[i], i));
		}
		ct.Sample();
		printf(&quot;map,    alpha,   %15llu\n&quot;, ct.Total()/1000000);
	}
	// test two, StringMap, insert dictionary, alphabetical order
	{
		// 62M, 131M in debug
		ct.Reset();
		StringMap&lt;int&gt; mapTest;
		for (size_t i = 0; i &lt; dictionary.size(); ++i)
		{
			mapTest.insert(dictionary[i].c_str(), i);
		}
		ct.Sample();
		printf(&quot;Strmap, alpha,   %15llu\n&quot;, ct.Total()/1000000);
	}
	std::random_shuffle(dictionary.begin(), dictionary.end());
	// following tests not measured in debug, std::map is so very much slower (more than 5x)
	// StringMap is approximately 2x slower
	// test one, map, insert dictionary, alphabetical order
	{
		// 551M
		ct.Reset();
		std::map&lt;std::string, int&gt; mapTest;
		for (size_t i = 0; i &lt; dictionary.size(); ++i)
		{
			mapTest.insert(std::pair&lt;std::string, int&gt;(dictionary[i], i));
		}
		ct.Sample();
		printf(&quot;map,    shuffle, %15llu\n&quot;, ct.Total()/1000000L);
	}
	// test two, StringMap, insert dictionary, alphabetical order
	{
		// 86M
		ct.Reset();
		StringMap&lt;int&gt; mapTest;
		for (size_t i = 0; i &lt; dictionary.size(); ++i)
		{
			mapTest.insert(dictionary[i].c_str(), i);
		}
		ct.Sample();
		printf(&quot;Strmap, shuffle, %15llu\n&quot;, ct.Total()/1000000L);
	}
	// Random find of everything
	{
		StringMap&lt;int&gt; mapTest;
		for (size_t i = 0; i &lt; dictionary.size(); ++i)
		{
			mapTest.insert(dictionary[i].c_str(), i);
		}
		std::map&lt;std::string, int&gt; mapTest2;
		for (size_t i = 0; i &lt; dictionary.size(); ++i)
		{
			mapTest2.insert(std::pair&lt;std::string, int&gt;(dictionary[i].c_str(), i));
		}
		std::random_shuffle(dictionary.begin(), dictionary.end());
		{
			// 87M
			ct.Reset();
			for (size_t i = 0; i &lt; dictionary.size(); ++i)
			{
				int data;
				mapTest.find(dictionary[i].c_str(), &amp;data);
			}
			ct.Sample();
			printf(&quot;Strmap, find,    %15llu\n&quot;, ct.Total()/1000000L);

			// 273M
			ct.Reset();
			for (size_t i = 0; i &lt; dictionary.size(); ++i)
			{
				int data;
				std::map&lt;std::string, int&gt;::iterator j = mapTest2.find(dictionary[i]);
			}
			ct.Sample();
			printf(&quot;map, find,       %15llu\n&quot;, ct.Total()/1000000L);
		}
	}&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Alexey, I can&#8217;t get the bufn&#8211; to display properly. I put a space in, it&#8217;s ugly but hopefully people will get it.</p>
<p>Here&#8217;s the dictionary.txt file I used:</p>
<p><a href="http://java.sun.com/docs/books/tutorial/collections/interfaces/examples/dictionary.txt" rel="nofollow">http://java.sun.com/docs/books/tutorial/collections/interfaces/examples/dictionary.txt</a></p>
<p>Here&#8217;s the timing code. I haven&#8217;t filled in a gcc version of the cycle timer. I would appreciate your timings with STLPort; I might imagine it to be much faster than the Dinkumware implementation Microsoft ships. Please also mention which compiler and settings you used.</p>
<p>Sorry for the screwball formatting, I need some kind of nice code display plugin&#8230;</p>
<p><code><br />
	class Cycles<br />
	{<br />
	public:<br />
		Cycles()<br />
		{<br />
			Reset();<br />
		}</p>
<p>		void Reset()<br />
		{<br />
			Sample();<br />
			start = cycles;<br />
		}</p>
<p>#ifdef _MSC_VER<br />
		void Sample()<br />
		{<br />
			int dwLow, dwHigh;<br />
			__asm<br />
			{<br />
				rdtsc<br />
				mov dwLow, eax<br />
				mov dwHigh, edx<br />
			}<br />
			cycles = ((unsigned long long)dwHigh < < 32) |<br />
				(unsigned long long) dwLow;<br />
		}<br />
#else<br />
		void Sample() { cycles = 0; }<br />
#endif</p>
<p>		unsigned long long Total() const { return cycles - start; }</p>
<p>		unsigned long long start;<br />
		unsigned long long cycles;<br />
	};</p>
<p>	std::vector<std::string> dictionary;<br />
	std::ifstream dict;<br />
	dict.open("d:\\dictionary.txt");<br />
	while (!dict.eof())<br />
	{<br />
		char buff[256];<br />
		dict.getline(buff, 256);<br />
		dictionary.push_back(buff);<br />
	}</p>
<p>	Base::Cycles ct;<br />
	// test one, map, insert dictionary, alphabetical order<br />
	{<br />
		// 565M, 3248M in debug<br />
		ct.Reset();<br />
		std::map<std ::string, int> mapTest;<br />
		for (size_t i = 0; i < dictionary.size(); ++i)<br />
		{<br />
			mapTest.insert(std::pair<std::string, int>(dictionary[i], i));<br />
		}<br />
		ct.Sample();<br />
		printf("map,    alpha,   %15llu\n", ct.Total()/1000000);<br />
	}<br />
	// test two, StringMap, insert dictionary, alphabetical order<br />
	{<br />
		// 62M, 131M in debug<br />
		ct.Reset();<br />
		StringMap<int> mapTest;<br />
		for (size_t i = 0; i < dictionary.size(); ++i)<br />
		{<br />
			mapTest.insert(dictionary[i].c_str(), i);<br />
		}<br />
		ct.Sample();<br />
		printf("Strmap, alpha,   %15llu\n", ct.Total()/1000000);<br />
	}<br />
	std::random_shuffle(dictionary.begin(), dictionary.end());<br />
	// following tests not measured in debug, std::map is so very much slower (more than 5x)<br />
	// StringMap is approximately 2x slower<br />
	// test one, map, insert dictionary, alphabetical order<br />
	{<br />
		// 551M<br />
		ct.Reset();<br />
		std::map<std::string, int> mapTest;<br />
		for (size_t i = 0; i < dictionary.size(); ++i)<br />
		{<br />
			mapTest.insert(std::pair<std::string, int>(dictionary[i], i));<br />
		}<br />
		ct.Sample();<br />
		printf("map,    shuffle, %15llu\n", ct.Total()/1000000L);<br />
	}<br />
	// test two, StringMap, insert dictionary, alphabetical order<br />
	{<br />
		// 86M<br />
		ct.Reset();<br />
		StringMap</int><int> mapTest;<br />
		for (size_t i = 0; i < dictionary.size(); ++i)<br />
		{<br />
			mapTest.insert(dictionary[i].c_str(), i);<br />
		}<br />
		ct.Sample();<br />
		printf("Strmap, shuffle, %15llu\n", ct.Total()/1000000L);<br />
	}<br />
	// Random find of everything<br />
	{<br />
		StringMap<int> mapTest;<br />
		for (size_t i = 0; i < dictionary.size(); ++i)<br />
		{<br />
			mapTest.insert(dictionary[i].c_str(), i);<br />
		}<br />
		std::map<std::string, int> mapTest2;<br />
		for (size_t i = 0; i < dictionary.size(); ++i)<br />
		{<br />
			mapTest2.insert(std::pair<std::string, int>(dictionary[i].c_str(), i));<br />
		}<br />
		std::random_shuffle(dictionary.begin(), dictionary.end());<br />
		{<br />
			// 87M<br />
			ct.Reset();<br />
			for (size_t i = 0; i < dictionary.size(); ++i)<br />
			{<br />
				int data;<br />
				mapTest.find(dictionary[i].c_str(), &#038;data);<br />
			}<br />
			ct.Sample();<br />
			printf("Strmap, find,    %15llu\n", ct.Total()/1000000L);</p>
<p>			// 273M<br />
			ct.Reset();<br />
			for (size_t i = 0; i < dictionary.size(); ++i)<br />
			{<br />
				int data;<br />
				std::map<std::string, int>::iterator j = mapTest2.find(dictionary[i]);<br />
			}<br />
			ct.Sample();<br />
			printf("map, find,       %15llu\n", ct.Total()/1000000L);<br />
		}<br />
	}</int></std></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://meshula.net/wordpress/?p=183&#038;cpage=1#comment-6527</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Tue, 08 Jul 2008 05:22:14 +0000</pubDate>
		<guid isPermaLink="false">http://meshula.net/wordpress/?p=183#comment-6527</guid>
		<description>Pseudonym,

My goal in wrapping Bentley &amp; Sedgewick&#039;s code was to use it almost verbatim. It is well known code that works well and has a large body of documentation to go with it, and I didn&#039;t really want to modify it for stylistic reasons. The only reason to wrap it was that as implemented you could have only one global tree, which is kind of useless. But wrapped into a class it became immediately useful.

In general, I would agree with you that simply slapping a class on C code is ugly, but I felt I was justified just this once :) 

I&#039;ll refer to this nice paper on the boost site on exception safety:

http://www.boost.org/community/exception_safety.html

Since the code I&#039;ve posted can&#039;t throw exceptions, I&#039;ll assume you are referring to the notion of dealing reasonably with error conditions (which this code doesn&#039;t, input checking would be an obvious improvement at little runtime burden), that resources aren&#039;t leaked (it doesn&#039;t, so that&#039;s one positive), and that errors are reported to the user (they aren&#039;t).

I&#039;ll certainly agree with you that this is not production quality code; it&#039;s meant to be illustrative of how a StringMap could take the place of a std::map with a string key.

I&#039;m afraid I have to agree with you that the freearr mechanism they proposed is not the clearest thing ever; I had to read it slowly for the ah-hah! light to go on. The sheer lightness of it did impress me though, so I figured why mess with it? It works.

As Alexey says it is common to use limited custom containers for performance reasons. So while I would definitely adopt remedies to the points you mention in production code, I would also not go and add all the extra bits (like a remove method) that would make the code larger and less focussed on doing one thing very well.</description>
		<content:encoded><![CDATA[<p>Pseudonym,</p>
<p>My goal in wrapping Bentley &#038; Sedgewick&#8217;s code was to use it almost verbatim. It is well known code that works well and has a large body of documentation to go with it, and I didn&#8217;t really want to modify it for stylistic reasons. The only reason to wrap it was that as implemented you could have only one global tree, which is kind of useless. But wrapped into a class it became immediately useful.</p>
<p>In general, I would agree with you that simply slapping a class on C code is ugly, but I felt I was justified just this once <img src='http://meshula.net/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p>I&#8217;ll refer to this nice paper on the boost site on exception safety:</p>
<p><a href="http://www.boost.org/community/exception_safety.html" rel="nofollow">http://www.boost.org/community/exception_safety.html</a></p>
<p>Since the code I&#8217;ve posted can&#8217;t throw exceptions, I&#8217;ll assume you are referring to the notion of dealing reasonably with error conditions (which this code doesn&#8217;t, input checking would be an obvious improvement at little runtime burden), that resources aren&#8217;t leaked (it doesn&#8217;t, so that&#8217;s one positive), and that errors are reported to the user (they aren&#8217;t).</p>
<p>I&#8217;ll certainly agree with you that this is not production quality code; it&#8217;s meant to be illustrative of how a StringMap could take the place of a std::map with a string key.</p>
<p>I&#8217;m afraid I have to agree with you that the freearr mechanism they proposed is not the clearest thing ever; I had to read it slowly for the ah-hah! light to go on. The sheer lightness of it did impress me though, so I figured why mess with it? It works.</p>
<p>As Alexey says it is common to use limited custom containers for performance reasons. So while I would definitely adopt remedies to the points you mention in production code, I would also not go and add all the extra bits (like a remove method) that would make the code larger and less focussed on doing one thing very well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexey</title>
		<link>http://meshula.net/wordpress/?p=183&#038;cpage=1#comment-6521</link>
		<dc:creator>Alexey</dc:creator>
		<pubDate>Mon, 07 Jul 2008 12:19:22 +0000</pubDate>
		<guid isPermaLink="false">http://meshula.net/wordpress/?p=183#comment-6521</guid>
		<description>Would you please provide us with your test code? My quick and dirty test does not show such dramatical difference between StringMap
 and STLport&#039;s std::map (at least not for find())...</description>
		<content:encoded><![CDATA[<p>Would you please provide us with your test code? My quick and dirty test does not show such dramatical difference between StringMap<br />
 and STLport&#8217;s std::map (at least not for find())&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexey</title>
		<link>http://meshula.net/wordpress/?p=183&#038;cpage=1#comment-6520</link>
		<dc:creator>Alexey</dc:creator>
		<pubDate>Mon, 07 Jul 2008 10:00:20 +0000</pubDate>
		<guid isPermaLink="false">http://meshula.net/wordpress/?p=183#comment-6520</guid>
		<description>Pseudonym,
It is common in game programming to use limited containers for performance reasons. It is quite scary for a game programmer to use *dynamic* container of pools to fight memory allocations :)
But in this case I bet Nick&#039;s goal was to make it as simple as possible, so I think it&#039;s ok.

PS. I seems the publishing system likes to eat some symbols, I&#039;m pretty sure &quot;if (bufn– == 0)&quot; should really be &quot;if (bufn–- == 0)&quot;!</description>
		<content:encoded><![CDATA[<p>Pseudonym,<br />
It is common in game programming to use limited containers for performance reasons. It is quite scary for a game programmer to use *dynamic* container of pools to fight memory allocations <img src='http://meshula.net/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
But in this case I bet Nick&#8217;s goal was to make it as simple as possible, so I think it&#8217;s ok.</p>
<p>PS. I seems the publishing system likes to eat some symbols, I&#8217;m pretty sure &#8220;if (bufn– == 0)&#8221; should really be &#8220;if (bufn–- == 0)&#8221;!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pseudonym</title>
		<link>http://meshula.net/wordpress/?p=183&#038;cpage=1#comment-6518</link>
		<dc:creator>Pseudonym</dc:creator>
		<pubDate>Mon, 07 Jul 2008 06:24:38 +0000</pubDate>
		<guid isPermaLink="false">http://meshula.net/wordpress/?p=183#comment-6518</guid>
		<description>I have some real problems with C-style programming in C++, not the least of which is that this code isn&#039;t exception-safe.

Most other high-performance C++ application areas wouldn&#039;t stand for that.  Is this common in games programming?

Anyway, some suggestions on how to make the C-style pool allocation work in C++.

First, I&#039;d replace each pool with a lightweight object that owns the pool.  Perhaps something like this:

struct Pool
{
    Tnode* buf;
    Pool() : buf(new Tnode[buffPoolGrowSize]) {}
    ~Pool() { delete[] buf; }
};

Another option is boost::scoped_array.

2. Replace freearr with a dynamic container of pools.  Probably std::deque is the best option here, because it doesn&#039;t do any copying.</description>
		<content:encoded><![CDATA[<p>I have some real problems with C-style programming in C++, not the least of which is that this code isn&#8217;t exception-safe.</p>
<p>Most other high-performance C++ application areas wouldn&#8217;t stand for that.  Is this common in games programming?</p>
<p>Anyway, some suggestions on how to make the C-style pool allocation work in C++.</p>
<p>First, I&#8217;d replace each pool with a lightweight object that owns the pool.  Perhaps something like this:</p>
<p>struct Pool<br />
{<br />
    Tnode* buf;<br />
    Pool() : buf(new Tnode[buffPoolGrowSize]) {}<br />
    ~Pool() { delete[] buf; }<br />
};</p>
<p>Another option is boost::scoped_array.</p>
<p>2. Replace freearr with a dynamic container of pools.  Probably std::deque is the best option here, because it doesn&#8217;t do any copying.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
