Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #15020
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe23.iad.POSTED!83aa503d!not-for-mail |
|---|---|
| From | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 |
| MIME-Version | 1.0 |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: case strings |
| References | <robns7d4t1tn9g0q8i1g0rph1g36cnk7ko@4ax.com> |
| In-Reply-To | <robns7d4t1tn9g0q8i1g0rph1g36cnk7ko@4ax.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Lines | 20 |
| Message-ID | <YVPyr.3287$At.402@newsfe23.iad> (permalink) |
| X-Complaints-To | abuse@newsrazor.net |
| NNTP-Posting-Date | Sun, 03 Jun 2012 20:37:12 UTC |
| Date | Sun, 03 Jun 2012 13:37:13 -0700 |
| X-Received-Bytes | 1752 |
| Xref | csiph.com comp.lang.java.programmer:15020 |
Show key headers only | View raw
On 6/3/12 11:40 AM, Roedy Green wrote: > has anyone benchmarked or decompiled to see how the new case string > labels are compiled. Are they faster than setting up a HashMap to > classify the strings? In theory they could be since the literal > values are known at compile time, where HashMap does not have that > advantage. > It took me a second to realize you meant switch/case with Strings. I thought you were talking about letter case and case sensitivity, and the rest became a non sequitur. I haven't looked into the mechanisms specifically, but I would imaging there could be significant optimizations that could be done at compile time (java->bytecode or bytecode->native), depending on size of the switch statement. On the other hand, a Map has other advantages (like being able to be dynamically defined). Use what ever is clearest for your use-case, then if, and only if, it isn't fast enough (as indicated by profiling tools), optimize it.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
case strings Roedy Green <see_website@mindprod.com.invalid> - 2012-06-03 11:40 -0700
Re: case strings Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-03 13:37 -0700
Re: case strings markspace <-@.> - 2012-06-03 19:19 -0700
Re: case strings Roedy Green <see_website@mindprod.com.invalid> - 2012-06-04 07:53 -0700
Re: case strings Lew <noone@lewscanon.com> - 2012-06-05 23:53 -0700
Re: case strings Roedy Green <see_website@mindprod.com.invalid> - 2012-06-04 07:57 -0700
Re: case strings "Mike Schilling" <mscottschilling@hotmail.com> - 2012-06-04 08:18 -0700
Re: case strings Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-06-04 11:30 -0400
Re: case strings Lew <noone@lewscanon.com> - 2012-06-06 00:15 -0700
csiph-web