Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #6775

Slow -- VERY slow brain

From "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com>
Newsgroups comp.lang.c++
Subject Slow -- VERY slow brain
Date 2011-06-16 01:08 +0200
Organization A noiseless patient Spider
Message-ID <itbdgg$aer$1@dont-email.me> (permalink)

Show all headers | View raw


Well, I think, it's not just me.

Since it's in the FAQ, and since we have discussed this for years, it must be 
nearly all of us: we're idiots.

I'm thinking of the argument for `unsigned` type, that you can do

   void foo( unsigned n )
   {
       assert( n < maxN );
       // blah
   }

which is reportedly both more concise and more efficient than

   void foo( int n )
   {
       assert( 0 <= n && n < maxN );
       // blah
   }

But, the second one can always be written as

   void foo( int n )
   {
       assert( unsigned( n ) < maxN );
       // blah
   }

which is perhaps not quite as concise, but is exactly as efficient (doing 
exactly the same), and moreover sort of forces you to think about what the first 
function's code really does --  which is the same as this.

In short, the efficiency argument is bogus.

Why did we not recognize that earlier (like, why is the bogus argument still in 
the FAQ with no counter-argument), or, perhaps, why have I not recognized this 
being mentioned in the postings about signed/unsigned?


Cheers,

- Alf  (wondering)

-- 
blog at <url: http://alfps.wordpress.com>

Back to comp.lang.c++ | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Slow -- VERY slow brain "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> - 2011-06-16 01:08 +0200
  Re: Slow -- VERY slow brain "Balog Pal" <pasa@lib.hu> - 2011-06-16 01:44 +0200
  Re: Slow -- VERY slow brain Puppet_Sock <puppet_sock@hotmail.com> - 2011-06-16 06:25 -0700
    Re: Slow -- VERY slow brain Noah Roberts <dont@email.me> - 2011-06-29 10:05 -0700
  Re: Slow -- VERY slow brain Keith H Duggar <duggar@alum.mit.edu> - 2011-06-16 07:00 -0700
  Re: Slow -- VERY slow brain "madamemandm@yahoo.com" <madamemandm@yahoo.com> - 2011-06-16 07:22 -0700
    Re: Slow -- VERY slow brain "madamemandm@yahoo.com" <madamemandm@yahoo.com> - 2011-06-16 07:31 -0700
      Re: Slow -- VERY slow brain "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> - 2011-06-16 18:51 +0200
        Re: Slow -- VERY slow brain "madamemandm@yahoo.com" <madamemandm@yahoo.com> - 2011-06-16 13:10 -0700
          Re: Slow -- VERY slow brain "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> - 2011-06-16 22:46 +0200
            Re: Slow -- VERY slow brain "madamemandm@yahoo.com" <madamemandm@yahoo.com> - 2011-06-17 07:38 -0700
              Re: Slow -- VERY slow brain Kai-Uwe Bux <jkherciueh@gmx.net> - 2011-06-17 18:06 +0200
                Re: Slow -- VERY slow brain "madamemandm@yahoo.com" <madamemandm@yahoo.com> - 2011-06-17 10:49 -0700
        Re: Slow -- VERY slow brain "Paul" <pchristor@yahoo.co.uk> - 2011-06-17 18:27 +0100
  Re: Slow -- VERY slow brain Werner <werasm@gmail.com> - 2011-06-17 01:33 -0700
    Re: Slow -- VERY slow brain Öö Tiib <ootiib@hot.ee> - 2011-06-17 07:48 -0700
      Re: Slow -- VERY slow brain Werner <werasm@gmail.com> - 2011-06-17 09:39 -0700
    Re: Slow -- VERY slow brain "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> - 2011-06-17 19:59 +0200

csiph-web