@@ -372,14 +372,12 @@ template< typename T, SizeT defaultLength> class ForInfoListT
372372private:
373373 T* eArr;
374374 char buf[defaultLength * sizeof (T)]; // prevent constructor calls
375- SizeT currentMaxLength;
376375 SizeT sz;
377376
378377public:
379378
380379 ForInfoListT (): eArr( reinterpret_cast <T*>(buf)), sz( 0 )
381- {
382- currentMaxLength=defaultLength;
380+ {
383381 }
384382
385383 ~ForInfoListT ()
@@ -397,51 +395,42 @@ template< typename T, SizeT defaultLength> class ForInfoListT
397395 // must be called before access
398396 void InitSize ( SizeT s)
399397 {
400- // std::cerr<<this<<": InitSize("<<s<<")\n";
401398 assert ( sz == 0 );
402399 if ( s == 0 )
403400 return ;
404- sz = 0 ;
405- if ( s <= currentMaxLength) // initialise currentMaxLength objects
401+ sz = s ;
402+ if ( s < defaultLength)
406403 {
407- for ( SizeT i=0 ; i<currentMaxLength ; ++i)
404+ for ( SizeT i=0 ; i<s ; ++i)
408405 eArr[ i].Init ();
409406 return ;
410407 }
411408 eArr = new T[ s]; // constructor called
412- currentMaxLength=s;
413409 }
414410 // only needed for EXECUTE
415411 void resize ( SizeT s)
416412 {
417- // std::cerr<<this<<": resize("<<s<<"): ";
418- if ( s == sz) {
419- // std::cerr<<" == "<<sz<<": return.\n";
413+ if ( s == sz)
420414 return ;
421- }
422415 if ( s < sz) // shrink
423416 {
424- // std::cerr << " < " << sz << ": shrink.\n";
425417 for ( SizeT i=s; i<sz; ++i)
426418 eArr[ i].ClearInit (); // in case eArr was allocated
427419 sz = s;
428420 return ;
429421 }
430422 // s > sz -> grow
431- if ( s <= currentMaxLength && eArr == reinterpret_cast <T*>(buf))
423+ if ( s <= defaultLength && eArr == reinterpret_cast <T*>(buf))
432424 {
433- // std::cerr << " > " << sz << " but <= currentMaxLength : grow.\n";
434425 for ( SizeT i=sz; i<s; ++i)
435426 eArr[ i].Init ();
436427 sz = s;
437428 return ;
438429 }
439430 // this should never happen (or only in extreme rarely cases)
440431 // the performance will go down
441- // s > currentMaxLength
442- // std::cerr << " > " << sz << " and > currentMaxLength : should not happen.\n";
432+ // s > defaultLength
443433 T* newArr = new T[ s]; // ctor called
444- currentMaxLength=s;
445434 if ( eArr != reinterpret_cast <T*>(buf))
446435 {
447436 for ( SizeT i=0 ; i<sz; ++i)
@@ -462,7 +451,7 @@ template< typename T, SizeT defaultLength> class ForInfoListT
462451 sz = s;
463452 }
464453 // T operator[]( SizeT i) const { assert( i<sz); return eArr[i];}
465- T& operator []( SizeT i) { assert ( i<currentMaxLength ); return eArr[i];}
454+ T& operator []( SizeT i) { assert ( i<sz ); return eArr[i];}
466455 SizeT size () const { return sz;}
467456 iterator begin () const { return &eArr[0 ];}
468457 iterator end () const { return &eArr[sz];}
@@ -474,6 +463,7 @@ template< typename T, SizeT defaultLength> class ForInfoListT
474463};
475464
476465
466+
477467// for UD subroutines (written in GDL) ********************************
478468class EnvUDT : public EnvBaseT
479469{
@@ -491,7 +481,8 @@ class EnvUDT: public EnvBaseT
491481 };
492482
493483private:
494- ForInfoListT<ForLoopInfoT, MAX_LOOPS_NUMBER> forLoopInfo; // defaults to $MAIN$ values in dpro.hpp
484+ ForInfoListT<ForLoopInfoT, 32 > forLoopInfo;
485+ // std::vector<ForLoopInfoT> forLoopInfo;
495486
496487 ProgNodeP ioError;
497488 DLong onError; // on_error setting
0 commit comments