🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.learn.c-c++
Article #774

Re: Fast acces to class method

#774
From: Fei Li
Date: Wed, 22 Mar 2000 00:00
41 lines
1798 bytes
dataman@cyberdude.com wrote:

> What is the fastest way for  accessing a member  in  a class.
>
> DATA is a structure;
>
> class A
> {
>   public:
>             //directly by having access to the member ?
>             DATA data;
>
>             //by return value
>             DATA GetData()
>             {
>               return data;
>             }
>
>            //by reference
>            void GetData(DATA& d)
>            {
>               d=data;
>            }
>
>            //by pointer
>            void GetData(DATA* pD)
>            {
>             *pData=data;
>            }
> }

    With a dumb compiler, direct access is probably the fastest.
     With a good compiler that applies inlining, return value optimization,

     etc,  probably no diffenrence among the 4 methods.

--
  *  Fei Li,                | (757)-865-0818                   *
  *  High Technology Corp.  | fli@htc-tech.com                 *
  *  28 Research Drive      | http://www.htc-tech.com/home/fli *
  *  Hampton, VA23666       |                                  *
Technical Details
Message-ID: <38D8E9A3.2300EB3B@htc-tech.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <38D8E693.34731AA0@cyberdude.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109fba,d558f056865fc0f1
X-Google-Attributes: gid109fba,public
X-Google-Thread: fdcad,d558f056865fc0f1
X-Google-Attributes: gidfdcad,public
X-Google-Thread: 114592,d558f056865fc0f1
X-Google-Attributes: gid114592,public
From: Fei Li <fli@htc-tech.com>
Subject: Re: Fast acces to class method
Date: 2000/03/22
Message-ID: <38D8E9A3.2300EB3B@htc-tech.com>
X-Deja-AN: 600900165
Content-Transfer-Encoding: 7bit
References: <38D8E693.34731AA0@cyberdude.com>
X-Accept-Language: en
Content-Type: text/plain; charset=gb2312
Organization: HTC
Mime-Version: 1.0
Newsgroups: alt.comp.lang.learn.c-c++,comp.lang.c++,fr.comp.lang.c++