Article View: rec.games.programmer
Article #2052Re: cout vs printf speed (was: Should I learn C or C++ first?)
From: Mumit Khan
Date: Thu, 07 Sep 1995 13:53
Date: Thu, 07 Sep 1995 13:53
38 lines
2159 bytes
2159 bytes
In article <42mnbt$psi@mksrv1.dseg.ti.com>, Geoffrey Rubin <grubin@ti.com> wrote: >In article <42kq70$8vu@martha.utcc.utk.edu>, mbk@caffeine.engr.utk.edu says... >> >>Eric Gunnerson (ericgu@microsoft.com) wrote: >> >> >>I.e. I don't understand the motivation for allowing tweaking with "new" >>when you could do it with normal routines, it seems like needless complexity. My sentiments exactly! > >The main advantage of using class specific news is the prevention of heap >fragmentation. SInce presummably all objects of the same class are the same >size, allocation/deallocation of these items from there own heap prevents >heap fragmentation. The create function you mentioned, would not do this >without much needed complication to maintain separate heaps for each size >allocation... > >Geoffrey > Sure, but then try to write special purpose allocators or dynamic allocators that allocate in a persistent heap or in shared memory or in regular transient heap depending on some run-time flag, and you'll see how limited this mechanism of defining per-class new operator really is. There is *nothing* stopping you from defining special allocators, such as string_allocator, node_allocator, etc that various classes use depending on the need, but these classes do not call some special new operator directly. BTW, this is one of the nice feature of STL implementation (actually the allocator design in ObjectSpace STL is much nicer), and lets you work much more effectively than if STL defined per-class new operators. regards mumit -- khan@xraylith.wisc.edu http://www.xraylith.wisc.edu/~khan/
Technical Details
Message-ID:
<42mth5$sqo@news.doit.wisc.edu>Path:
arc1-ca.pugleaf.net!news.doit.wisc.edu!khanReferences:
<DDJ2Lp.3DG@pentagon-ai.army.mil> <42ibl0$kfq@news2100.microsoft.com> <42kq70$8vu@martha.utcc.utk.edu> <42mnbt$psi@mksrv1.dseg.ti.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.doit.wisc.edu!khan From: khan@xraylith.wisc.edu (Mumit Khan) Newsgroups: rec.games.programmer,comp.lang.c++ Subject: Re: cout vs printf speed (was: Should I learn C or C++ first?) Date: 7 Sep 1995 13:53:41 GMT Organization: Center for X-ray Lithography, UW-Madison Message-ID: <42mth5$sqo@news.doit.wisc.edu> References: <DDJ2Lp.3DG@pentagon-ai.army.mil> <42ibl0$kfq@news2100.microsoft.com> <42kq70$8vu@martha.utcc.utk.edu> <42mnbt$psi@mksrv1.dseg.ti.com> NNTP-Posting-Host: modi.xraylith.wisc.edu