🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3697

Re: String value of enum

#3697
From: Bill Leonard
Date: Sat, 16 Mar 1996 10:17
45 lines
2928 bytes
In article <KANZE.96Mar15151356@gabi.gabi-soft.fr>, kanze@gabi-soft.fr
(J. Kanze) writes:

> At start-up, yes.  If the map is large enough for this to make a
> difference, however, it's likely that the difference between the O(ln n)
> binary search and a O(k) hash table look-up is also significant.

I wasn't thinking of a large table, I was thinking of lots of small ones.

> Given that the enum labels are all in the source code, and programmers
> being on the whole a lazy group of people, the resulting tables are
> typically so small that it really doesn't make a difference, especially
> since anytime that the conversion is necessary, output will follow.

I agree that the performance of the conversion itself is not an issue.
However, startup cost might be if you have lots of these tables in an
application whose execution is normally of very short duration.  Adding 100
milliseconds, say, to an application that only executes for a few hundred
milliseconds anyway is a big penalty.

My point is simply that static initialization is better, I think.

-- 
Bill Leonard
Harris Computer Systems Corporation
2101 W. Cypress Creek Road
Fort Lauderdale, FL  33309
Bill.Leonard@mail.hcsc.com

These opinions and statements are my own and do not necessarily reflect the
opinions or positions of Harris Computer Systems Corporation.

------------------------------------------------------------------------------
There's something wrong with an industry in which amazement is a common
reaction to things going right.

"Hard work never scared me.  Oh, sure, it has startled me from a distance."
                                                       -- Professor Fishhawk
------------------------------------------------------------------------------
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
Technical Details
Message-ID: <4ictq6$r43@ns.hcsc.com>
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
References: <4i5sf3$89c@hermes.is.co.za> <Do81tp.H9u@rsvl.unisys.com> <4i8a38$2qq@engnews1.Eng.Sun.COM> <4i9cn4$7cf@ns.hcsc.com> <KANZE.96Mar15151356@gabi.gabi-soft.fr>

Show Full Headers
Complete Article Headers
From: bill@amber.ssd.hcsc.com (Bill Leonard)
Message-ID: <4ictq6$r43@ns.hcsc.com>
X-Original-Date: 15 Mar 1996 23:17:26 GMT
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
Date: 16 Mar 96 10:17:19 GMT
Approved: fjh@cs.mu.oz.au
Return-Path: <daemon@meeker.UCAR.EDU>
Newsgroups: comp.std.c++
Subject: Re: String value of enum
Organization: Harris Computer Systems, Ft. Lauderdale FL
References: <4i5sf3$89c@hermes.is.co.za> <Do81tp.H9u@rsvl.unisys.com>  <4i8a38$2qq@engnews1.Eng.Sun.COM> <4i9cn4$7cf@ns.hcsc.com> <KANZE.96Mar15151356@gabi.gabi-soft.fr>
Reply-To: Bill.Leonard@mail.hcsc.com
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMUqVTOEDnX0m9pzZAQGt8gGAgDkpokQ/XILnz31JbigFS07mWpQ4QEU5
 j+A9xI3szM38Rx9f31GYqwRYtV+vgH2v
 =phno