2014-03-18 14:12 GMT+01:00 Jon Harper <jon.harpe...@gmail.com>: > In this case, it's more complicated then a single with-destructor scope, > because I use the destructors to call libyaml's destroy function on the > struct, so that the same memory can be reused between the calls to libyaml > for this struct. So I really need to destroy it right away before the next > call the libyaml, hence the nested with-destructors. > > I could allocate new memory for those structs every time and destroy them > only at the end of the parsing. But in most cases, only one struct is needed > at a given time, so I thought reusing them was a good thing. > Jon
I think you're falling for the premature optimization trap here. Allocating memory is incredibly cheap so unless your code is memory constrained there is no need to save on it. It's always better to start with the simplest implementation you can get away with and then if you run into performance problems start to optimize it. -- mvh/best regards Björn Lindqvist ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech _______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk