@@ -74,9 +74,9 @@ class SchedEntry {
7474 void setOffsets (float x, float y, float z);
7575 int getZone () const ;
7676 void setZone (int z);
77- string getFileName () const ;
77+ const string& getFileName () const ;
7878 void setFileName (const string& s);
79- string getProgramName () const ;
79+ const string& getProgramName () const ;
8080 void setProgramName (const string& s);
8181 float getFeedOverride () const ;
8282 void setFeedOverride (float f);
@@ -146,15 +146,15 @@ void SchedEntry::setZone(int z) {
146146 zone = z;
147147 }
148148
149- string SchedEntry::getFileName () const {
149+ const string& SchedEntry::getFileName () const {
150150 return fileName;
151151 }
152152
153153void SchedEntry::setFileName (const string& s) {
154154 fileName = s;
155155 }
156156
157- string SchedEntry::getProgramName () const {
157+ const string& SchedEntry::getProgramName () const {
158158 return programName;
159159 }
160160
@@ -369,7 +369,7 @@ int getProgramById(int id, qRecType *qRec) {
369369 for (i=q.begin (); i!=q.end (); ++i) {
370370 if (i->getTagId () == id) break ;
371371 }
372- if (i->getTagId () != id) return -1 ;
372+ if (i == q. end () || i ->getTagId () != id) return -1 ;
373373 qRec->priority = i->getPriority ();
374374 qRec->tagId = i->getTagId ();
375375 i->getOffsets (qRec->xpos , qRec->ypos , qRec->zpos );
@@ -384,14 +384,11 @@ int getProgramById(int id, qRecType *qRec) {
384384
385385int getProgramByIndex (int idx, qRecType *qRec) {
386386 list<SchedEntry>::iterator i;
387- int index;
388387
389- if ((unsigned int ) idx >= q.size ()) return -1 ;
390- index = 0 ;
391- for (i=q.begin (); i!=q.end (); ++i) {
392- if (index == idx) break ;
393- index++;
394- }
388+ for (i = q.begin (); idx > 0 ; ++i) {
389+ if (i == q.end ()) return -1 ; // return if idx was larger than number of entries
390+ --idx;
391+ }
395392 qRec->priority = i->getPriority ();
396393 qRec->tagId = i->getTagId ();
397394 i->getOffsets (qRec->xpos , qRec->ypos , qRec->zpos );
0 commit comments