Received: by 10.68.196.130 with SMTP id im2mr9925167pbc.3.1326791841925; Tue, 17 Jan 2012 01:17:21 -0800 (PST) X-BeenThere: falconpl@googlegroups.com Received: by 10.68.51.72 with SMTP id i8ls20856946pbo.5.gmail; Tue, 17 Jan 2012 01:17:21 -0800 (PST) Received: by 10.68.190.99 with SMTP id gp3mr9932158pbc.1.1326791841713; Tue, 17 Jan 2012 01:17:21 -0800 (PST) Received: by 10.68.190.99 with SMTP id gp3mr9932156pbc.1.1326791841704; Tue, 17 Jan 2012 01:17:21 -0800 (PST) Return-Path: Received: from vps779.inmotionhosting.com (vps779.inmotionhosting.com. [74.124.203.179]) by gmr-mx.google.com with ESMTPS id c6si28446650pbo.0.2012.01.17.01.17.21 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 Jan 2012 01:17:21 -0800 (PST) Received-SPF: neutral (google.com: 74.124.203.179 is neither permitted nor denied by best guess record for domain of g...@niccolai.cc) client-ip=74.124.203.179; Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 74.124.203.179 is neither permitted nor denied by best guess record for domain of g...@niccolai.cc) smtp.mail...@niccolai.cc Received: from 93-35-251-232.ip57.fastwebnet.it ([93.35.251.232]:57871 helo=[10.189.57.139]) by vps779.inmotionhosting.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1Rn5AM-000DJh-Mh for falconpl@googlegroups.com; Tue, 17 Jan 2012 01:17:21 -0800 Message-ID: <4F153C9A.2000002@niccolai.cc> Date: Tue, 17 Jan 2012 10:17:14 +0100 From: Giancarlo Niccolai User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110921 Thunderbird/3.1.15 ThunderBrowse/3.8 MIME-Version: 1.0 To: falconpl@googlegroups.com Subject: Re: {FalconPL} enumerator callback question References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vps779.inmotionhosting.com X-AntiAbuse: Original Domain - googlegroups.com X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - niccolai.cc On 17/01/2012 03:43, Paul Nema wrote: > Updating classes, like classstring.cpp, classarray.cpp, etc. > > For function: void ClassString::enumerateProperties( void*, > Class::PropertyEnumerator& cb ) const > > PropertyEnumerator operator cb is called for each class method. > > Class String has 26 methods, so 26 cb calls (I.E. cb( "methodName", > false ); etc+25 ) each time this class is instantiated. > Could be expensive when creating a lot of arrays. > > There are more efficient way to perform this. > Examples: > 1. A comma delimited string of methods Btw, what makes you think that a n-times call to the enumerator callback is less efficient than 1) Allocating a dynamic string 2) concatenate strings n times into that (which often means reallocating the string) 3) call the callback once 4) have the callback calling n times findnext(',') 5) creating n times a substring from , to , (with the extra checks for the last string, and possibly dynamic allocation for each substring if the string algos are not VERY smart) 6) destroying the string Also, consider having to call n times next() on the iterator of a map. Unless it's inlined, you're not gaining much on the callback approach (also, jumping on the map leaves causes loss of memory locality). Gian.