Switch to reference parameters as appropriate.
authorScott Cantor <cantor.2@osu.edu>
Tue, 10 Mar 2009 01:46:54 +0000 (01:46 +0000)
committerScott Cantor <cantor.2@osu.edu>
Tue, 10 Mar 2009 01:46:54 +0000 (01:46 +0000)
xmltooling/util/TemplateEngine.cpp
xmltooling/util/TemplateEngine.h

index 22881e3..2333c8c 100644 (file)
@@ -206,20 +206,19 @@ void TemplateEngine::process(
                 trimspace(key);
                 lastpos = thispos + 1; // strlen(">")
             }
-            const vector<xmltooling::TemplateEngine::TemplateParameters> forParams = parameters.getParameterCollection(key.c_str());
 
-            unsigned int forend = forParams.size();
-            if (forend==0) {  // have to go through at least once to match end tags
+            const vector<TemplateParameters>& forParams = parameters.getParameterCollection(key.c_str());
+            vector<TemplateParameters>::size_type forend = forParams.size();
+            if (forend == 0) {  // have to go through at least once to match end tags
                cond = false;
                forend = 1;
             }
 
             const char *savlastpos = lastpos;
-            for (unsigned int i=0; i<forend; i++ ) {
-                const TemplateParameters nullp;
-                const TemplateParameters* tp = forParams.size()>0? static_cast<const TemplateParameters*>(&forParams[i]): &nullp;
+            for (vector<TemplateParameters>::size_type i=0; i<forend; ++i) {
+                static TemplateParameters nullp;
                 lastpos = savlastpos;
-                process(cond, buf, lastpos, os, *tp, e);
+                process(cond, buf, lastpos, os, (forParams.size()>0 ? forParams[i] : nullp), e);
             }
 
         }
index ad4027b..4023b52 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2007 Internet2
+ *  Copyright 2001-2009 Internet2
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -100,7 +100,7 @@ namespace xmltooling {
              * @param name  name of parameter collection
              * @return vector of parameters
              */
-            virtual const std::vector<TemplateParameters> getParameterCollection(const char* name) const {
+            virtual const std::vector<TemplateParameters>& getParameterCollection(const char* name) const {
                 std::map<std::string,std::vector<TemplateParameters> >::const_iterator i=m_collectionMap.find(name);
                 return (i->second);
             }