<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-20029661</id><updated>2011-04-21T23:36:03.840+01:00</updated><title type='text'>Dumped in Coldfusion</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://cfdumped.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://cfdumped.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>David</name><uri>http://www.blogger.com/profile/09468883053001599289</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-20029661.post-8633000232829319820</id><published>2007-12-31T13:05:00.000Z</published><updated>2007-12-31T13:34:13.476Z</updated><title type='text'>Week numbers in SimpleDateFormat</title><content type='html'>It seems that if you use week numbers in formats in java, then you can get stuffed, as there is no way to find out the year that corresponds to the week number that you're looking for.&lt;br /&gt;&lt;br /&gt;Today is the 31st December 2007, which is week 1 of 2008. Java correctly says that the week is week 1, and that the year is 2007. Unfortunately this is a little ambiguous, and NOT USEFUL for writing logs.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;  public static void main(String[] args) throws ParseException {&lt;br /&gt;    DateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);&lt;br /&gt;&lt;br /&gt;    DateFormat output = new SimpleDateFormat("yyyy-ww", Locale.ENGLISH);&lt;br /&gt;&lt;br /&gt;    final Date firstDay = format.parse("2007-01-01");&lt;br /&gt;    final Date lastDay = format.parse("2007-12-31");&lt;br /&gt;&lt;br /&gt;    System.out.println("First: " + output.format(firstDay) + " - " + format.format(firstDay));&lt;br /&gt;    System.out.println("Last : " + output.format(lastDay) + " - " + format.format(lastDay));&lt;br /&gt;  }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Generates the output &lt;br /&gt;&lt;pre&gt;&lt;br /&gt;First: 2007-01 - 2007-01-01&lt;br /&gt;Last : 2007-01 - 2007-12-31&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;If you are using &lt;code&gt;strftime&lt;/code&gt; in C etc., then you can use %G for the year, but if you're in java, then you're a bit stuffed.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;       %G     The ISO 8601 year with century as a decimal number.  The 4-digit&lt;br /&gt;              year corresponding to the ISO week number (see  %V).   This  has&lt;br /&gt;              the  same  format  and  value as %y, except that if the ISO week&lt;br /&gt;              number belongs to the previous or next year, that year  is  used&lt;br /&gt;              instead. (TZ)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Good job I picked today to look at log file naming. &lt;br /&gt;&lt;br /&gt;It seems that it isn't possible to make &lt;a href="http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html"&gt;a tomcat valve&lt;/a&gt; rotate to a new log weekly. I guess we'll have to go with daily or monthly.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Update:&lt;/span&gt; Sun have bugs open for this, &lt;a href="http://bugs.sun.com/view_bug.do?bug_id=4267450"&gt;4267450&lt;/a&gt; opened in 1999 and &lt;a href="http://bugs.sun.com/view_bug.do?bug_id=4808661"&gt;4808661&lt;/a&gt; a request for 1.6, and many others.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20029661-8633000232829319820?l=cfdumped.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfdumped.blogspot.com/feeds/8633000232829319820/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20029661&amp;postID=8633000232829319820' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/8633000232829319820'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/8633000232829319820'/><link rel='alternate' type='text/html' href='http://cfdumped.blogspot.com/2007/12/week-numbers-in-simpledateformat.html' title='Week numbers in SimpleDateFormat'/><author><name>David</name><uri>http://www.blogger.com/profile/09468883053001599289</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20029661.post-6618271156011629146</id><published>2007-11-09T15:31:00.000Z</published><updated>2007-11-09T15:38:20.640Z</updated><title type='text'>Autoboxing making people lazy</title><content type='html'>When writing in Java5 primitive types get automatically converted to objects if they are needed. This means that you can write code like:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;  map.put(1,4);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;where before you needed&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;  map.put(Long.valueOf(1), Long.valueOf(4));&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This is nice, and makes code prettier and easier to read.&lt;br /&gt;&lt;br /&gt;Unfortunately it makes programmers lazy, and they don't pay attention to if they are using &lt;code&gt;Long&lt;/code&gt; or &lt;code&gt;long&lt;/code&gt; in methods, and may pass a &lt;code&gt;Long&lt;/code&gt; to a method that takes a &lt;code&gt;long&lt;/code&gt;. Like this:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public void suspicious(Long l) {&lt;br /&gt;  foo(l); // &lt;-- Here&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;private void foo(long l) {&lt;br /&gt;  System.err.println("Long was: " + l);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;One problem is that the JVM will be creating and deleting lots of boxing objects all over the place if your code is particularly inconsistent. However, there's a more subtle problem. This code can now NPE at the line marked &lt;code&gt;Here&lt;/code&gt;, and it's can be difficult to track down.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20029661-6618271156011629146?l=cfdumped.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfdumped.blogspot.com/feeds/6618271156011629146/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20029661&amp;postID=6618271156011629146' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/6618271156011629146'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/6618271156011629146'/><link rel='alternate' type='text/html' href='http://cfdumped.blogspot.com/2007/11/autoboxing-making-people-lazy.html' title='Autoboxing making people lazy'/><author><name>David</name><uri>http://www.blogger.com/profile/09468883053001599289</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20029661.post-1632640684849681864</id><published>2007-11-09T15:29:00.000Z</published><updated>2007-11-09T15:30:43.474Z</updated><title type='text'>Convert integers to strings in java</title><content type='html'>If you have an integer, and want a string, concatenating it with "" is not as good as String.valueOf. It generates loads more code.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;int i = 5;&lt;br /&gt;&lt;br /&gt;String s1 = "" + i;            // BAD&lt;br /&gt;String s2 = String.valueOf(i); // GOOD&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I realise that it's a bit more typing, but it is clearer what you want, and it is more efficient.&lt;br /&gt;&lt;br /&gt;This also works for all the other unboxed types. long, boolean etc.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20029661-1632640684849681864?l=cfdumped.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfdumped.blogspot.com/feeds/1632640684849681864/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20029661&amp;postID=1632640684849681864' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/1632640684849681864'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/1632640684849681864'/><link rel='alternate' type='text/html' href='http://cfdumped.blogspot.com/2007/11/convert-integers-to-strings-in-java.html' title='Convert integers to strings in java'/><author><name>David</name><uri>http://www.blogger.com/profile/09468883053001599289</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20029661.post-8571023793501177556</id><published>2007-04-23T13:27:00.000+01:00</published><updated>2007-04-23T13:31:09.829+01:00</updated><title type='text'>Logging in and AJAX</title><content type='html'>This is an interesting problem. You have parts of a site that users can see without being logged in. Some of the actions on these pages are AJAX requests that do require the user to be logged in. &lt;br /&gt;&lt;br /&gt;Does anyone know any cool ways of handling the login, or sites that do this? The normal "redirect to login page that redirects back" option doesn't seem to work for this sort of thing.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20029661-8571023793501177556?l=cfdumped.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfdumped.blogspot.com/feeds/8571023793501177556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20029661&amp;postID=8571023793501177556' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/8571023793501177556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/8571023793501177556'/><link rel='alternate' type='text/html' href='http://cfdumped.blogspot.com/2007/04/logging-in-and-ajax.html' title='Logging in and AJAX'/><author><name>David</name><uri>http://www.blogger.com/profile/09468883053001599289</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20029661.post-2047675248636379717</id><published>2007-04-18T12:10:00.000+01:00</published><updated>2007-04-18T12:13:22.864+01:00</updated><title type='text'>List lengths</title><content type='html'>If you have a list in JSP and want to know how long it is then you have to use a function from the JSTL. It isn't 'built-in'. &lt;br /&gt;&lt;pre&gt;${fn:length(items)}&lt;/pre&gt;&lt;br /&gt;which means you need&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;%@ taglib prefix='fn' uri='http://java.sun.com/jsp/jstl/functions' %&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;elsewhere.&lt;br /&gt;&lt;br /&gt;How annoying (and hard to find).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20029661-2047675248636379717?l=cfdumped.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfdumped.blogspot.com/feeds/2047675248636379717/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20029661&amp;postID=2047675248636379717' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/2047675248636379717'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/2047675248636379717'/><link rel='alternate' type='text/html' href='http://cfdumped.blogspot.com/2007/04/list-lengths.html' title='List lengths'/><author><name>David</name><uri>http://www.blogger.com/profile/09468883053001599289</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20029661.post-6295482762314922394</id><published>2007-04-13T11:13:00.000+01:00</published><updated>2007-04-13T11:16:31.256+01:00</updated><title type='text'>JSP Horror!</title><content type='html'>I no longer work with Coldfusion on a daily basis, but I have discovered why people use it. JSPs are even worse! It seems that the only way to replace newlines in a string is to assign a newline to a variable, and then use that.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;c:set var="nl" value="&lt;br /&gt;" /&gt;&lt;br /&gt;&amp;lt;input type="hidden" name="address" value='${fn:replace(user.address, nl, "&amp;amp;#10;")}'/&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This just seems so flaky. &lt;br /&gt;&lt;br /&gt;Is there not a better way? (And I'm not sure that writing a custom tag is a better way).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20029661-6295482762314922394?l=cfdumped.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfdumped.blogspot.com/feeds/6295482762314922394/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20029661&amp;postID=6295482762314922394' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/6295482762314922394'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/6295482762314922394'/><link rel='alternate' type='text/html' href='http://cfdumped.blogspot.com/2007/04/jsp-horror.html' title='JSP Horror!'/><author><name>David</name><uri>http://www.blogger.com/profile/09468883053001599289</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20029661.post-115980071926682645</id><published>2006-10-02T15:47:00.000+01:00</published><updated>2006-10-27T10:11:34.758+01:00</updated><title type='text'>Static awstats and persistent perl</title><content type='html'>Sorry, not a Coldfusion post this time. I've been safely away from it recently.&lt;br /&gt;&lt;br /&gt;There have been several security problems with awstats that have lead to us not wanting to run it dynamically. There is also the load that it can create affecting the user-experience of people browsing the stats. Therefore we run awstats to generate the content statically. &lt;br /&gt;&lt;br /&gt;As we have to run awstats 20 times for each directory on our sites, this takes a lot of time just starting up perl and parsing all the libraries. I have now installed persistent perl on the log generating machine and changed awstats.pl to use pperl rather than perl and it is about 6 times faster and doesn't appear to have broken it. Excelent.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20029661-115980071926682645?l=cfdumped.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfdumped.blogspot.com/feeds/115980071926682645/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20029661&amp;postID=115980071926682645' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/115980071926682645'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/115980071926682645'/><link rel='alternate' type='text/html' href='http://cfdumped.blogspot.com/2006/10/static-awstats-and-persistent-perl.html' title='Static awstats and persistent perl'/><author><name>David</name><uri>http://www.blogger.com/profile/09468883053001599289</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20029661.post-115892533359323074</id><published>2006-09-22T12:28:00.000+01:00</published><updated>2006-10-27T10:11:34.699+01:00</updated><title type='text'>Bad hash function causes problems with ColdFusion Structs</title><content type='html'>I was looking at the slightly complicated series of structs that are used in the &lt;a href="http://www.bpurcell.org/blog/index.cfm?entry=963&amp;mode=entry"&gt;cf_accelerate&lt;/a&gt; tag. According to &lt;a href="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=964"&gt;discussions&lt;/a&gt; on the speed of structs the speed of ColdFusion structures gets really slow when you put more an more entries in them.&lt;br /&gt;&lt;br /&gt;One of the commenters noted that by reversing the keys he could get a significant speedup. It seems that this is all to do with a bad choice of Hash function deep in ColdFusion.&lt;br /&gt;&lt;br /&gt;A Hash table is a datastructure that is designed for fast lookups of keys. It uses a hash function to guess where something will be, then goes to check. This allows it to be faster than the average case in a lot of cases as you can find what you are looking for first time, rather than having to search through a list of entries, or use a complicated tree structure. Unfortunately if you look in the same place for two entries it still has to fall back on looking through them one by one, and so looses all of the speed advantages.&lt;br /&gt;&lt;br /&gt;Choosing a hash function is a compromise. On one hand, the hash function gets called a lot, often in speed critical code (which is why I was surprised that java.net.URL uses DNS in its .equals method, but that is another topic), however the other aim of hash codes is to differentiate different inputs. At one extreme, a constant hash code fulfills all the &lt;span style="font-weight:bold;"&gt;requirements&lt;/span&gt; of the fast hash code, but it isn't very useful as your hash table becomes slow like a list.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/2621/374/1600/shortkey.1.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger/2621/374/200/shortkey.1.jpg" border="0" alt="Example of a key with the characters used in the hash code highlighted" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The hash function choosen for the keys to structs in ColdFusion uses an evenly distributed selection of 4 of the letters from the key. These start with the first letter, then sample the rest of the key, as shown in the example to the left. The green-underlined letters are used to form the hash code.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/2621/374/1600/longkey.jpg"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger/2621/374/200/longkey.jpg" border="0" alt="Example of a longer key with the characters used in the hash code highlighted" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The key to why all of the benchmarks (and many common use cases) show that it is slow is that this sampling breaks down when you have a long, constant prefix on all of your structure keys. In this case (as seen to the right), the algorithm will hash all of your keys to the same place.&lt;br /&gt;&lt;br /&gt;Some people use really short keys in their Structs. These are nearly as bad as all keys less than 4 characters long are hashed based only on their first character, so ABB will hash to the same thing as AAA.&lt;br /&gt;&lt;br /&gt;So there are two ways that the algorithm chosen breaks down. Unfortunately both of these are commonly used by people choosing keys for structs. Given that the special algorithm that has been implemented in ColdFusion probably took a programmer time to implement, it had better be a lot faster than Java's built-in &lt;code&gt;hashCode&lt;/code&gt; method on &lt;code&gt;String&lt;/code&gt;'s in most cases given that it trivially fails to differentiate keys in common situations.&lt;br /&gt;&lt;br /&gt;To show an this, lets take one of the examples quoted by &lt;a href="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;amp;entry=964"&gt;a commenter&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;    &amp;lt;cfset s = structNew()&gt;&lt;br /&gt;    &amp;lt;cfloop from="1" to="100000" index="idx"&gt;&lt;br /&gt;     &amp;lt;cfset s["xxxx#idx#"] = 0&gt;&lt;br /&gt;    &amp;lt;/cfloop&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;He claims that this takes 6 minutes, compared to 1 second for a similar piece of code using a simple &lt;code&gt;java.util.HashMap&lt;/code&gt;. When you look at the hash algorithm you start to see why. Although there are 100,000 items in the hash table, only 91 hash codes are used. So rather than the maybe 1 or 2 lookups that would be expected in a hash table to find where to put/find a key, there are up to 1100, averaging 550. That is, due to this badly designed hash function, lookups into the structs do on average 550 times as much work as they could.&lt;br /&gt;&lt;br /&gt;If you reverse the keys then it is a lot faster as it uses 1010 hashcodes, and normally does 50 lookups for each entry. In contrast the standard hashcode used by Java for Strings gives every one of the 100,000 keys a different hashcode, allowing the keys to be found instantly.&lt;br /&gt;&lt;br /&gt;In summary, be very careful what you use for the keys of your structs if you are going to create very large structures then use them in speed critical code. It is probably safest not to do this and to use &lt;code&gt;java.util.HashMap&lt;/code&gt; objects instead if you want speed. For everyday use with small structs and very different keys this will not be a problem to you, but if you do start seeing slowdown in your struct accesses then consider this a possible reason.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20029661-115892533359323074?l=cfdumped.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfdumped.blogspot.com/feeds/115892533359323074/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20029661&amp;postID=115892533359323074' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/115892533359323074'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/115892533359323074'/><link rel='alternate' type='text/html' href='http://cfdumped.blogspot.com/2006/09/bad-hash-function-causes-problems-with.html' title='Bad hash function causes problems with ColdFusion Structs'/><author><name>David</name><uri>http://www.blogger.com/profile/09468883053001599289</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20029661.post-115330097960332134</id><published>2006-07-19T10:20:00.000+01:00</published><updated>2006-10-27T10:11:34.642+01:00</updated><title type='text'>Consistency in logs</title><content type='html'>Looking through the logs today I get a little confused by the dates in my coldfusion logs. At least I wasn't trying to grep to find what happened today, it appears a little confused about where in the world it lives. Maybe this is our fault, but it is a little confusing.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;07/19 08:35:58 Information [main] - ColdFusion started&lt;br /&gt;19/07 08:35:58 user ColdFusionStartUpServlet: ColdFusion MX: application services are now available&lt;br /&gt;19/07 08:35:58 user CFSwfServlet: init&lt;br /&gt;19/07 08:35:58 user CFCServlet: init&lt;br /&gt;19/07 08:35:59 user FlashGateway: init&lt;br /&gt;19/07 08:35:59 user CFFormGateway: init&lt;br /&gt;19/07 08:35:59 user CFInternalServlet: init&lt;br /&gt;Server coldfusion ready (startup time: 29 seconds)&lt;br /&gt;07/19 09:40:49 Error [jrpp-23] - File not found: ...&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20029661-115330097960332134?l=cfdumped.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfdumped.blogspot.com/feeds/115330097960332134/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20029661&amp;postID=115330097960332134' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/115330097960332134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/115330097960332134'/><link rel='alternate' type='text/html' href='http://cfdumped.blogspot.com/2006/07/consistency-in-logs.html' title='Consistency in logs'/><author><name>David</name><uri>http://www.blogger.com/profile/09468883053001599289</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20029661.post-114259021262425168</id><published>2006-03-17T09:58:00.000Z</published><updated>2006-10-27T10:11:34.534+01:00</updated><title type='text'>Heap analysis</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/2621/374/1600/memory.jpg"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger/2621/374/320/memory.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;This is the memory use graph for one of our sites. Does it scream "memory leak" to you? What do I do next to work out what is taking up all of that memory, could it be some sort of harmless Coldfusion caching (I suspect not)?&lt;br /&gt;&lt;br /&gt;I like graphs and nice analysis. I don't like sites that go off and sulk without telling me why. More and more I am realising that debugging a site that doesn't break until many people use it is hard unless you have instrumented your system beforehand. You can't just restart it every 5 minutes to put a bit more debugging in, as the people using it get pissed off (Coldfusion taking about 30 seconds to restart doesn't help this).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20029661-114259021262425168?l=cfdumped.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfdumped.blogspot.com/feeds/114259021262425168/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20029661&amp;postID=114259021262425168' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/114259021262425168'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/114259021262425168'/><link rel='alternate' type='text/html' href='http://cfdumped.blogspot.com/2006/03/heap-analysis.html' title='Heap analysis'/><author><name>David</name><uri>http://www.blogger.com/profile/09468883053001599289</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20029661.post-114131543655385430</id><published>2006-03-02T16:00:00.000Z</published><updated>2006-10-27T10:11:34.477+01:00</updated><title type='text'>Default variable scope</title><content type='html'>The default scope for variables you use in functions is global. If you want a local variable, you have to declare it at the beginning of your function. &lt;br /&gt;&lt;br /&gt;I realised this when I added logging to the end of one of my functions, and discovered that the variables that I was logging had changed value by the logging code. I now understand that this is to be expected with recursive methods.&lt;br /&gt;&lt;br /&gt;I don't object to having to declare all my variables as this is a good habit (though hard without decent tool support, is there something as nice as &lt;a href="http://www.intellij.com"&gt;Idea&lt;/a&gt; for Coldfusion?).&lt;br /&gt;&lt;br /&gt;It seems that &lt;a href="http://www.oreillynet.com/pub/a/javascript/2002/02/22/udftips.html"&gt;these coldfusion UDF tips&lt;/a&gt; are a good read, tip 3 tells you to Var your variables to make them local. What sort of madman made them global by default. Ick ick ick.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20029661-114131543655385430?l=cfdumped.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfdumped.blogspot.com/feeds/114131543655385430/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20029661&amp;postID=114131543655385430' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/114131543655385430'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/114131543655385430'/><link rel='alternate' type='text/html' href='http://cfdumped.blogspot.com/2006/03/default-variable-scope.html' title='Default variable scope'/><author><name>David</name><uri>http://www.blogger.com/profile/09468883053001599289</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20029661.post-114000958987106711</id><published>2006-02-15T13:03:00.000Z</published><updated>2006-10-27T10:11:34.417+01:00</updated><title type='text'>No finally in ColdFusion</title><content type='html'>Coldfusion has gained exceptions at some point, and they have been bolted on quite nicely. Unfortunately they appear to have missed out some parts of the try...catch idiom.&lt;br /&gt;&lt;br /&gt;Firstly you cannot do exception handling from  &lt;code&gt;&amp;lt;cfscript&amp;gt;&lt;/code&gt; tags. This means that if you write a lot of code as cfscript, in order to save on the world supply of angle brackets that would otherwise be absorbed, then you have to keep on switching in and out of cfscript making it even messier.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Update: It appears that you can use try/catch in cfscript. I just found some code that appears to be basically &lt;code&gt;try {} catch (Any exception) {} &lt;/code&gt; &lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Secondly, though there is &lt;code&gt;&amp;lt;cftry&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;cfcatch&amp;gt;&lt;/code&gt;, it appears to be missing a &lt;code&gt;&amp;lt;cffinally&amp;gt;&lt;/code&gt;. &lt;br /&gt;&lt;br /&gt;Surely finally is something that is used quite a bit for tidying up after code. In some cases you can just put the clean-up code outside the try block, but that doesn't work if your code has a &lt;code&gt;&amp;lt;cfabort&amp;gt;&lt;/code&gt; or is a user defined function with a return. &lt;br /&gt;&lt;br /&gt;This leads to cutting and pasting code between the end of the try-block and the catch-blocks with all of the chances for error that entails. &lt;br /&gt;&lt;br /&gt;This just further enforces my thought that Coldfusion is just for VB and PHP programmers that don't have alergic reations to messy code. That said, there are a lot of these "programmers" about, and Coldfusion does a lot of the clearing up for you, reducing the need for finally.&lt;br /&gt;&lt;br /&gt;I still think it should be there, for completeness if nothing else.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20029661-114000958987106711?l=cfdumped.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfdumped.blogspot.com/feeds/114000958987106711/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20029661&amp;postID=114000958987106711' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/114000958987106711'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/114000958987106711'/><link rel='alternate' type='text/html' href='http://cfdumped.blogspot.com/2006/02/no-finally-in-coldfusion.html' title='No finally in ColdFusion'/><author><name>David</name><uri>http://www.blogger.com/profile/09468883053001599289</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20029661.post-113984241725807080</id><published>2006-02-13T14:51:00.000Z</published><updated>2006-10-27T10:11:34.360+01:00</updated><title type='text'>Displaying DateTimes in Coldfusion</title><content type='html'>It seems that there is no way of formatting a date with a time in Coldfusion. Yes, you can format a date, and yes, you can format a time, but the combination appears to be lacking.&lt;br /&gt;&lt;br /&gt;You get most of the way there with something like&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;  #DateFormat(date, "dd mmm yyyy HH:mm:ss")#&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;However you may after a while notice that all of the times have the same number of minutes. Astute readers will have noticed that "mm" means "2 digit month number", not "2 digit minutes". Now the documentation implies that HH and ss should have just shown up as the letters, not as the representations of the time part of the DateTime.&lt;br /&gt;&lt;br /&gt;Obviously what you have to do is&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;  #DateFormat(date, "dd mm yyyy")# #TimeFormat(date, "HH:mm:ss")#&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Surely there should be a way of doing this as one command. Why are they different methods anyway? Most languages manage to formate date-times with the same functions.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20029661-113984241725807080?l=cfdumped.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cfdumped.blogspot.com/feeds/113984241725807080/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20029661&amp;postID=113984241725807080' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/113984241725807080'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20029661/posts/default/113984241725807080'/><link rel='alternate' type='text/html' href='http://cfdumped.blogspot.com/2006/02/displaying-datetimes-in-coldfusion.html' title='Displaying DateTimes in Coldfusion'/><author><name>David</name><uri>http://www.blogger.com/profile/09468883053001599289</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
