[commit] r2432 - in trunk/GME: Common Meta Mga

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Tue Feb 18 16:28:51 CST 2014


Author: ksmyth
Date: Tue Feb 18 16:28:51 2014
New Revision: 2432

Log:
Microoptimization

Modified:
   trunk/GME/Common/CommonSmart.h
   trunk/GME/Meta/MgaMetaRegNode.cpp
   trunk/GME/Mga/MgaLibOps.cpp

Modified: trunk/GME/Common/CommonSmart.h
==============================================================================
--- trunk/GME/Common/CommonSmart.h	Tue Feb 18 16:28:39 2014	(r2431)
+++ trunk/GME/Common/CommonSmart.h	Tue Feb 18 16:28:51 2014	(r2432)
@@ -10,6 +10,8 @@
 #include <AtlBase.h>
 #endif
 
+#include<string>
+
 // --------------------------- CComObjPtr
 
 // in containers we need the default "operator &",
@@ -420,9 +422,13 @@
 {
 public:
 	template<class T>
-	PutInBstr(const T t) { CopyTo(t, b); }
+	PutInBstr(const T& t) { CopyTo(t, b); }
+
+	template<> PutInBstr(const BSTR& a) : b(a) { }
 
-	template<> PutInBstr(BSTR a) : b(a) { }
+	template<> PutInBstr(const std::wstring& t) {
+		b.p = SysAllocStringLen(t.c_str(), t.length());
+	}
 
 	operator BSTR () { return b; }
 

Modified: trunk/GME/Meta/MgaMetaRegNode.cpp
==============================================================================
--- trunk/GME/Meta/MgaMetaRegNode.cpp	Tue Feb 18 16:28:39 2014	(r2431)
+++ trunk/GME/Meta/MgaMetaRegNode.cpp	Tue Feb 18 16:28:51 2014	(r2432)
@@ -14,8 +14,7 @@
 	{
 		CCoreObjectPtr self(me);
 
-		std::string path;
-		CopyTo(bpath, path);
+		std::wstring path = bpath;
 
 		CComObjPtr<ICoreProject> coreproject;
 		COMTHROW( self->get_Project(PutOut(coreproject)) );
@@ -23,11 +22,10 @@
 
 		for(;;)
 		{
-			size_t pos = path.find('/');//pos will be either in range 0..len-1 or will be equal with string::npos 
-			std::string name(path, 0, pos);
+			size_t pos = path.find(L'/');//pos will be either in range 0..len-1 or will be equal with string::npos 
+			std::wstring name(path, 0, pos);
 
-			CComBstrObj bname;
-			CopyTo(name, bname);
+			CComBstrObj bname(name.c_str());
 
 			CCoreObjectPtr node;
 

Modified: trunk/GME/Mga/MgaLibOps.cpp
==============================================================================
--- trunk/GME/Mga/MgaLibOps.cpp	Tue Feb 18 16:28:39 2014	(r2431)
+++ trunk/GME/Mga/MgaLibOps.cpp	Tue Feb 18 16:28:51 2014	(r2432)
@@ -420,19 +420,19 @@
 				ASSERT( dumper != NULL );
 
 				COMTHROW(dumper->put_FormatVersion(0));
-				COMTHROW(dumper->DumpProject( p, PutInBstr( szTempXmeFileName)) );
+				COMTHROW(dumper->DumpProject( p, _bstr_t(szTempXmeFileName)) );
 
 				COMTHROW(p->Close(VARIANT_FALSE));
 
 				// Create a new 'paradigmname' project
 				COMTHROW(connstr_upgraded.Append( szTempMgaFileName)); // connection string prepared
-				hr = p->CreateEx( PutInBstr( connstr_upgraded), PutInBstr( paradigmname), paradigmGUID);
+				hr = p->CreateEx(connstr_upgraded, paradigmname, paradigmGUID);
 				if( SUCCEEDED( hr)) {
 					CComPtr<IMgaParser> parser;
 					COMTHROW( parser.CoCreateInstance(L"Mga.MgaParser") );
 					ASSERT( parser != NULL );
 
-					COMTHROW(parser->ParseProject( p, PutInBstr( szTempXmeFileName)) );
+					COMTHROW(parser->ParseProject( p, _bstr_t(szTempXmeFileName)) );
 					COMTHROW(p->Close(VARIANT_FALSE));
 					upgraded = true;
 				}


More information about the gme-commit mailing list