Hi Jakob, Jakob Lund wrote: >> Jakob Lund wrote: >>> Every note that gets played still causes a `new Note` being issued in >>> hydrogen.cpp -- am I right that this is potentially a problem? If so, we >> Yes, but it's been low on the priority list because it's not known to >> create a problem. Also, std::vector<> (and maybe std::dequeue<>) has a >> block of memory pre-allocated (and larger than the vector). So, it's >> usually only a problem if you exceed that storage range. > > The Note objects are created with 'new', and the POINTERS to them get stored > on a std::priority_queue. Even if the queue behaves nicely, the object > allocation may (and, as it seems happens most often, may not) cause > problems -- but can we be _sure_ it will not, as long as we use 'new' ?
Jakob, we agree on this. When I say that it's "low on the priority list" I mean that "I plan to fix it, but I that imagine Sebastian and Michael are rolling their eyes at me for being so anal about this stuff -- so I don't think it's a show stopper." :-) Also, many of the fixes we're doing to get a stable 0.9.4 release will probably become obsolete by the transport redesign. I've been mulling over solutions... but haven't gotten very far in the process. >> I will often use references instead of pointers because (a) I like to use >> '.' notation rather than '->' pointer dereferencing and (b) you don't have >> to constantly test to see if someone passed you a null or invalid pointer. > > All very well, but that doesn't account for the situation in hydrogen.cpp; > please read, compile and run the attached dog example to see what I mean! Yes, inserting a Note* into a std::queue will not call the Note constructor. Likewise, using a container of heavy objects (e.g. std::deque<Note>) will use 'new' and call the constructor every time something is inserted. But the queue is already using pointers, isn't it? In your previous post, it sounded like you said that operator<(Note&, Note&) would call the Note constructors -- and that is false. That's all I was saying here. Peace, Gabriel ------------------------------------------------------------------------------ Enter the BlackBerry Developer Challenge This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/blackberry _______________________________________________ Hydrogen-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/hydrogen-devel
