Improve performance on structs
[scilab.git] / scilab / modules / ast / src / cpp / types / struct.cpp
index 3fde4f6..b2076b0 100644 (file)
@@ -614,17 +614,15 @@ std::vector<InternalType*> Struct::extractFields(typed_list* _pArgs)
         {
             break;
         }
-        else if (iIndex > (int)get(0)->getData().size() + 2)
+        else if (iIndex > (int)get(0)->getNumFields() + 2)
         {
             break;
         }
         else if (getSize() == 1)
         {
             //return elements
-            std::list<InternalType*> pData = get(0)->getData();
-            std::list<InternalType*>::iterator it = pData.begin();
-            std::advance(it, iIndex - 3);
-            ResultList.push_back((*it)->clone());
+            const std::vector<InternalType*> & pData = get(0)->getData();
+            ResultList.push_back(pData[iIndex - 3]->clone());
         }
         else
         {
@@ -634,10 +632,8 @@ std::vector<InternalType*> Struct::extractFields(typed_list* _pArgs)
             for (int j = 0 ; j < getSize() ; j++)
             {
                 //-2 for fieldlist and dims, -1 for indexed at 0
-                std::list<InternalType*> pData = get(j)->getData();
-                std::list<InternalType*>::iterator it = pData.begin();
-                std::advance(it, iIndex - 3);
-                pL->append((*it)->clone());
+                const std::vector<InternalType*> & pData = get(j)->getData();
+                pL->append(pData[iIndex - 3]->clone());
             }
 
             ResultList.push_back(pL);