[Libreoffice-commits] core.git: hwpfilter/source

Julien Nabet serval2412 at yahoo.fr
Mon Oct 9 21:06:30 UTC 2017


 hwpfilter/source/formula.cxx |    9 +++------
 hwpfilter/source/grammar.cxx |   13 +++++--------
 hwpfilter/source/nodes.h     |    5 ++---
 3 files changed, 10 insertions(+), 17 deletions(-)

New commits:
commit adb946f9845dff9f5a53010b38032247b30475c1
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Sun Oct 8 20:35:23 2017 +0200

    Replace list by vector for nodelist var (hwpfilter)
    
    Change-Id: I693d01f63b8bd8b2c78bfd98e1f9310c965f65b2
    Reviewed-on: https://gerrit.libreoffice.org/43262
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/hwpfilter/source/formula.cxx b/hwpfilter/source/formula.cxx
index c3d3b9ce4f2b..5ab06f91dd9b 100644
--- a/hwpfilter/source/formula.cxx
+++ b/hwpfilter/source/formula.cxx
@@ -613,12 +613,9 @@ void Formula::parse()
      if( res ){
           makeMathML( res );
      }
-     int count = nodelist.size();
-     for( i = 0 ; i < count ; i++ ){
-         const Node *tmpNode = nodelist.front();
-         nodelist.pop_front();
-         delete tmpNode;
-     }
+     for (const auto &node : nodelist)
+         delete node;
+     nodelist.clear();
 }
 
 void Formula::trim()
diff --git a/hwpfilter/source/grammar.cxx b/hwpfilter/source/grammar.cxx
index 8c593a01315a..ec0fae08411a 100644
--- a/hwpfilter/source/grammar.cxx
+++ b/hwpfilter/source/grammar.cxx
@@ -28,7 +28,7 @@
 #define YYMAXDEPTH 0
 #endif
 
-#include <list>
+#include <vector>
 #include <stdlib.h>
 #include <string.h>
 
@@ -40,7 +40,7 @@ extern "C" {
 #include "grammar.h"
 }
 
-std::list<Node*> nodelist;
+std::vector<Node*> nodelist;
 
 void yyerror(const char *);
 
@@ -1191,12 +1191,9 @@ void yyerror(const char * /*err*/)
 {
 //  printf("REALKING ERR[%s]\n",err);
     // if error, delete all nodes.
-    int ncount = nodelist.size();
-    for( int i = 0 ; i < ncount ; i++){
-        Node *pNode = nodelist.front();
-        nodelist.pop_front();
-        delete pNode;
-    }
+    for (const auto &node : nodelist)
+        delete node;
+    nodelist.clear();
     top = nullptr;
 }
 
diff --git a/hwpfilter/source/nodes.h b/hwpfilter/source/nodes.h
index 01fc85fad7ef..61db3a818137 100644
--- a/hwpfilter/source/nodes.h
+++ b/hwpfilter/source/nodes.h
@@ -22,7 +22,7 @@
 
 #include <sal/config.h>
 
-#include <list>
+#include <vector>
 #include <stdio.h>
 #include <stdlib.h>
 #include <osl/diagnose.h>
@@ -94,8 +94,7 @@ public:
      Node *child;
      Node *next;
 };
-
-extern std::list<Node *> nodelist;
+extern std::vector<Node *> nodelist;
 
 #endif
 


More information about the Libreoffice-commits mailing list