🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++
Article #26

Re: fetching the multi-dimensional array classes

#26
From: Piercarlo Grandi
Date: Fri, 30 Jun 1989 11:25
23 lines
1547 bytes
In article <8906281652.AA04026@AENEAS.MIT.EDU> SAITO@sdr.slb.com ("Naoki Saito  Ext. 5471", GEO-002) writes:

	[ on multiple dimensional arrays ]

    And the definition of the fetching method is something like this:
    
    float& Matrix::operator(int i, int j)
    {
      return buf[i*cols+j]; // return without checking the index.
    }

Two minor points: you wanted to write "Matrix::operator()(int i,int j)" of
course, and most importantly, I hope you defined it as inline (explcitly or
implicitly within the class definition).

For such small functions, inlining is vital, not just because of speed but
also because it *reduces* total code size, as the function body is tipically
smaller than the code size used by the caller to prepare and close the call
(or the clee to so prologue and epilogue), especially on CISC machines.
-- 
Piercarlo "Peter" Grandi           | ARPA: pcg%cs.aber.ac.uk@nsfnet-relay.ac.uk
Dept of CS, UCW Aberystwyth        | UUCP: ...!mcvax!ukc!aber-cs!pcg
Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@cs.aber.ac.uk
Technical Details
Message-ID: <1041@aber-cs.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!yunexus!telly!attcan!uunet!mcvax!ukc!dcl-cs!aber-cs!pcg

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!yunexus!telly!attcan!uunet!mcvax!ukc!dcl-cs!aber-cs!pcg
From: pcg@aber-cs.UUCP (Piercarlo Grandi)
Newsgroups: gnu.g++
Subject: Re: fetching the multi-dimensional array classes
Summary: INLINE!
Message-ID: <1041@aber-cs.UUCP>
Date: 30 Jun 89 11:25:37 GMT
Article-I.D.: aber-cs.1041
Reply-To: pcg@cs.aber.ac.uk (Piercarlo Grandi)
Distribution: gnu
Organization: Dept of CS, UCW Aberystwyth
 (Disclaimer: my statements are purely personal)
Lines: 23