home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- From: nikki@trmphrst.demon.co.uk (Nikki Locke)
- Path: sparky!uunet!pipex!demon!trmphrst.demon.co.uk!nikki
- Subject: Re: Small objs & When/whether to overload "new" with statics
- Reply-To: nikki@trmphrst.demon.co.uk
- References: <1993Jan04.162941.13841@rchland.ibm.com>
- Distribution: world
- X-Mailer: cppnews $Revision: 1.30 $
- Organization: Trumphurst Ltd.
- Lines: 38
- Date: Tue, 5 Jan 1993 18:34:19 +0000
- Message-ID: <726284059snx@trmphrst.demon.co.uk>
- Sender: usenet@demon.co.uk
-
- In article <1993Jan04.162941.13841@rchland.ibm.com> lwloen@rchland.vnet.ibm.com writes:
- [ BitRef class def omitted]
-
- > Now, I am less interested in the particular virtues and vices of
- > BitRef per se than in what to do _in general_ with helper objects of
- > that kind. Note carefully that in the normal course of events, BitRef
- > will never be formally declared. It will arise, normally, as a temporary
- > in various objects' operator[]. There are many such potential objects.
- >
- > Optimizing such objects can be important, especially if they "help"
- > functions like operator[], because they may appear in inner "for" loops.
-
- One obvious optimisation would be to adjust data to point to the actual
- byte containing the bit you want, so that loc is always between 0 and 7.
-
- > I especially wonder about "new" and "delete".
- >
- > For machines with enough registers, one presumes that the above code
- > could work out fairly nicely, as is. Each data element of an instance
- > of BitRef could imaginably have both of its small pieces optimized into
- > a register, especially since the compiler, since it creates it, is in
- > full control of how long the instances live.
- >
- > For a PC-type machine, however, such optimization seems unlikely (is
- > that so?).
-
- It is so on all the compilers I have used. I don't think I have ever seen
- a PC compiler optimise a structure into registers.
-
- > Therefore, _if_ the compiler's generation of "temps" uses
- > new and delete, one would be tempted to add something like the following
- > to BitRef
-
- Ah, but they don't (as a rule), they allocate space on the stack.
-
- --
- Nikki Locke,Trumphurst Ltd.(PC and Unix consultancy) nikki@trmphrst.demon.co.uk
- trmphrst.demon.co.uk is NOT affiliated with ANY other sites at demon.co.uk.
-