Hello RG team,

Concerning this from the bugs list:
>   Also includes a fix to iterator range typo in
> MidiDevice (not my fault
>   this time, it looks like it might be Julie's) which
> caused a crash in
>   replaceControlParameters() (iterator was bounded
> with <= end() rather
>   than < end())

Sorry, about that.  How silly.

But it does bring up a coding style issue.

I see lots of code that looks like this:
>     for(; cIt != con.end(); ++cIt) {

And as Chris fixed, I see this.
>     for(; cIt < con.end(); ++cIt) {

My understanding is technically both should work since .end() is a one-past the 
range.

My Java brain tells me that the "<" method is a safer method incase something 
goes wrong and cIt somehow get advanced twice before the next check and the 
"!=" would make the assumption the cIt will always only get incremented one 
postion at a time.

Put I see much C++ that prefers to use the != idiom.

In RG I see it mixed like in src/commands/notation/AddMarkCommand.cpp:

>    for (size_t i = 0; i < marks.size(); ++i) {
Makes sence since size is 1 greater than the index.

then we have later:
>    for (i = m_selection->getSegmentEvents().begin();
>         i != m_selection->getSegmentEvents().end(); ++i) {

Same idea, isn't it.

So is this just an idiom or style thing, or I there something, I'm not 
understanding?

Sincerely,
Julie S.



      

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Rosegarden-devel mailing list
[email protected] - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Reply via email to