[PATCH] fdo#57950: Remove chained appends in dbaccess

Marcos Souza (via Code Review) gerrit at gerrit.libreoffice.org
Tue Jan 8 19:48:26 PST 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/1604

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/04/1604/1

fdo#57950: Remove chained appends in dbaccess

Also remove some rtl:: prefixes.

Change-Id: If9a1090b1c8daea03c3e39f8cfd2f395dd1c337b
Signed-off-by: Marcos Paulo de Souza <marcos.souza.org at gmail.com>
---
M dbaccess/source/ui/misc/WCopyTable.cxx
M dbaccess/source/ui/querydesign/QueryDesignView.cxx
2 files changed, 32 insertions(+), 48 deletions(-)



diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx
index 5edb86e..2521c74 100644
--- a/dbaccess/source/ui/misc/WCopyTable.cxx
+++ b/dbaccess/source/ui/misc/WCopyTable.cxx
@@ -235,37 +235,35 @@
     return new OFieldDescription( xColumn );
 }
 //------------------------------------------------------------------------
-::rtl::OUString ObjectCopySource::getSelectStatement() const
+OUString ObjectCopySource::getSelectStatement() const
 {
-    ::rtl::OUString sSelectStatement;
+    OUString sSelectStatement;
     if ( m_xObjectPSI->hasPropertyByName( PROPERTY_COMMAND ) )
     {   // query
         OSL_VERIFY( m_xObject->getPropertyValue( PROPERTY_COMMAND ) >>= sSelectStatement );
     }
     else
     {   // table
-        ::rtl::OUStringBuffer aSQL;
-        aSQL.appendAscii( "SELECT " );
+        OUStringBuffer aSQL( "SELECT " );
 
         // we need to create the sql stmt with column names
         // otherwise it is possible that names don't match
-        const ::rtl::OUString sQuote = m_xMetaData->getIdentifierQuoteString();
+        const OUString sQuote = m_xMetaData->getIdentifierQuoteString();
 
-        Sequence< ::rtl::OUString > aColumnNames = getColumnNames();
-        const ::rtl::OUString* pColumnName = aColumnNames.getConstArray();
-        const ::rtl::OUString* pEnd = pColumnName + aColumnNames.getLength();
+        Sequence< OUString > aColumnNames = getColumnNames();
+        const OUString* pColumnName = aColumnNames.getConstArray();
+        const OUString* pEnd = pColumnName + aColumnNames.getLength();
         for ( ; pColumnName != pEnd; )
         {
             aSQL.append( ::dbtools::quoteName( sQuote, *pColumnName++ ) );
 
             if ( pColumnName == pEnd )
-                aSQL.appendAscii( " " );
+                aSQL.append( " " );
             else
-                aSQL.appendAscii( ", " );
+                aSQL.append( ", " );
         }
 
-        aSQL.appendAscii( "FROM " );
-        aSQL.append( ::dbtools::composeTableNameForSelect( m_xConnection, m_xObject ) );
+        aSQL.append( "FROM " + ::dbtools::composeTableNameForSelect( m_xConnection, m_xObject ) );
 
         sSelectStatement = aSQL.makeStringAndClear();
     }
@@ -418,14 +416,10 @@
     return NULL;
 }
 //------------------------------------------------------------------------
-::rtl::OUString NamedTableCopySource::getSelectStatement() const
+OUString NamedTableCopySource::getSelectStatement() const
 {
-    ::rtl::OUStringBuffer aSQL;
-    aSQL.appendAscii( "SELECT * FROM " );
-
-    aSQL.append( ::dbtools::composeTableNameForSelect( m_xConnection, m_sTableCatalog, m_sTableSchema, m_sTableBareName ) );
-
-    return aSQL.makeStringAndClear();
+    return OUString( "SELECT * FROM " +
+                     ::dbtools::composeTableNameForSelect( m_xConnection, m_sTableCatalog, m_sTableSchema, m_sTableBareName ) );
 }
 
 //------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
index 9ef92b9..c1c6ba7 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -289,11 +289,11 @@
         return eErrorCode;
     }
     //------------------------------------------------------------------------------
-    ::rtl::OUString BuildJoinCriteria(  const Reference< XConnection>& _xConnection,
-                                        const OConnectionLineDataVec* pLineDataList,
-                                        const OQueryTableConnectionData* pData)
+    OUString BuildJoinCriteria(  const Reference< XConnection>& _xConnection,
+                                 const OConnectionLineDataVec* pLineDataList,
+                                 const OQueryTableConnectionData* pData)
     {
-        ::rtl::OUStringBuffer aCondition;
+        OUStringBuffer aCondition;
         if ( _xConnection.is() )
         {
             OConnectionLineDataVec::const_iterator aIter = pLineDataList->begin();
@@ -301,19 +301,19 @@
             try
             {
                 const Reference< XDatabaseMetaData >  xMetaData = _xConnection->getMetaData();
-                const ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString();
-                const ::rtl::OUString sEqual(RTL_CONSTASCII_USTRINGPARAM(" = "));
+                const OUString aQuote = xMetaData->getIdentifierQuoteString();
+                const OUString sEqual(" = ");
 
                 for(;aIter != aEnd;++aIter)
                 {
                     OConnectionLineDataRef pLineData = *aIter;
                     if(aCondition.getLength())
                         aCondition.append(C_AND);
-                    aCondition.append(quoteTableAlias(sal_True,pData->GetAliasName(JTCS_FROM),aQuote));
-                    aCondition.append(::dbtools::quoteName(aQuote, pLineData->GetFieldName(JTCS_FROM) ));
-                    aCondition.append(sEqual);
-                    aCondition.append(quoteTableAlias(sal_True,pData->GetAliasName(JTCS_TO),aQuote));
-                    aCondition.append(::dbtools::quoteName(aQuote, pLineData->GetFieldName(JTCS_TO) ));
+                    aCondition.append(quoteTableAlias(sal_True,pData->GetAliasName(JTCS_FROM),aQuote) +
+                                     ::dbtools::quoteName(aQuote, pLineData->GetFieldName(JTCS_FROM) ) +
+                                     sEqual +
+                                     quoteTableAlias(sal_True,pData->GetAliasName(JTCS_TO),aQuote) +
+                                     ::dbtools::quoteName(aQuote, pLineData->GetFieldName(JTCS_TO) ));
                 }
             }
             catch(SQLException&)
@@ -683,11 +683,7 @@
                     if  ( pEntryField->isAggreateFunction() )
                     {
                         OSL_ENSURE(!pEntryField->GetFunction().isEmpty(),"Functionname darf hier nicht leer sein! ;-(");
-                        ::rtl::OUStringBuffer aTmpStr2( pEntryField->GetFunction());
-                        aTmpStr2.appendAscii("(");
-                        aTmpStr2.append(aTmpStr.makeStringAndClear());
-                        aTmpStr2.appendAscii(")");
-                        aTmpStr = aTmpStr2;
+                        aTmpStr = pEntryField->GetFunction() + "(" + aTmpStr.makeStringAndClear() + ")";
                     }
 
                     if (!rFieldAlias.isEmpty()                         &&
@@ -695,11 +691,9 @@
                         pEntryField->isNumericOrAggreateFunction()      ||
                         pEntryField->isOtherFunction()))
                     {
-                        aTmpStr.append(s_sAs);
-                        aTmpStr.append(::dbtools::quoteName(aQuote, rFieldAlias));
+                        aTmpStr.append(s_sAs + ::dbtools::quoteName(aQuote, rFieldAlias));
                     }
-                    aFieldListStr.append(aTmpStr.makeStringAndClear());
-                    aFieldListStr.append(sFieldSeparator);
+                    aFieldListStr.append(aTmpStr.makeStringAndClear() + sFieldSeparator);
                 }
             }
             if(aFieldListStr.getLength())
@@ -2916,17 +2910,14 @@
         aCriteriaListStr = aTmp;
     }
     // ----------------- Statement aufbauen ----------------------
-    ::rtl::OUStringBuffer aSqlCmd(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT ")));
+    OUStringBuffer aSqlCmd("SELECT ");
     if(static_cast<OQueryController&>(getController()).isDistinct())
-        aSqlCmd.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" DISTINCT ")));
-    aSqlCmd.append(aFieldListStr);
-    aSqlCmd.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FROM ")));
-    aSqlCmd.append(aTableListStr);
+        aSqlCmd.append(" DISTINCT ");
+    aSqlCmd.append(aFieldListStr + " FROM " + aTableListStr);
 
     if (aCriteriaListStr.getLength())
     {
-        aSqlCmd.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE ")));
-        aSqlCmd.append(aCriteriaListStr.makeStringAndClear());
+        aSqlCmd.append(" WHERE " + aCriteriaListStr.makeStringAndClear());
     }
     // ----------------- GroupBy aufbauen und Anh"angen ------------
     Reference<XDatabaseMetaData> xMeta;
@@ -2940,8 +2931,7 @@
     // ----------------- having Anh"angen ------------
     if(aHavingStr.getLength())
     {
-        aSqlCmd.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" HAVING ")));
-        aSqlCmd.append(aHavingStr.makeStringAndClear());
+        aSqlCmd.append(" HAVING " + aHavingStr.makeStringAndClear());
     }
     // ----------------- Sortierung aufbauen und Anh"angen ------------
     ::rtl::OUString sOrder;

-- 
To view, visit https://gerrit.libreoffice.org/1604
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If9a1090b1c8daea03c3e39f8cfd2f395dd1c337b
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Marcos Souza <marcos.souza.org at gmail.com>



More information about the LibreOffice mailing list