Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2583

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/83/2583/1

fdo#57950: Remove chained appends in codemaker

And another cleanups like removing RTL_CONST* macros and other simple
things.

Much more can be done inside codemaker.

Change-Id: I338e1c0e88558124741c6202896355533535a129
---
M codemaker/source/codemaker/codemaker.cxx
M codemaker/source/commoncpp/commoncpp.cxx
M codemaker/source/commonjava/commonjava.cxx
M codemaker/source/cppumaker/cpputype.cxx
M codemaker/source/javamaker/javatype.cxx
5 files changed, 44 insertions(+), 108 deletions(-)



diff --git a/codemaker/source/codemaker/codemaker.cxx b/codemaker/source/codemaker/codemaker.cxx
index 454f59c..6c203bf 100644
--- a/codemaker/source/codemaker/codemaker.cxx
+++ b/codemaker/source/codemaker/codemaker.cxx
@@ -66,11 +66,8 @@
     return s;
 }
 
-rtl::OString errorMsg(rtl::OString const & desc, rtl::OString const & type) {
-    rtl::OStringBuffer msg(128);
-    msg.append(desc);
-    msg.append(type);
-    return msg.makeStringAndClear();
+OString errorMsg(OString const & desc, OString const & type) {
+    return desc + type;
 }
 
 codemaker::UnoType::Sort decomposeAndResolve(
diff --git a/codemaker/source/commoncpp/commoncpp.cxx b/codemaker/source/commoncpp/commoncpp.cxx
index 989052d..5db10d4 100644
--- a/codemaker/source/commoncpp/commoncpp.cxx
+++ b/codemaker/source/commoncpp/commoncpp.cxx
@@ -37,7 +37,7 @@
 
 namespace codemaker { namespace cpp {
 
-rtl::OString scopedCppName(rtl::OString const & type, bool ns_alias)
+OString scopedCppName(OString const & type, bool ns_alias)
 {
     char c('/');
     sal_Int32 nPos = type.lastIndexOf( c );
@@ -49,12 +49,11 @@
         c = '.';
     }
 
-    rtl::OStringBuffer tmpBuf(type.getLength()*2);
+    OStringBuffer tmpBuf(type.getLength()*2);
     nPos = 0;
     do
     {
-        tmpBuf.append("::");
-        tmpBuf.append(type.getToken(0, c, nPos));
+        tmpBuf.append("::" + type.getToken(0, c, nPos));
     } while( nPos != -1 );
 
     rtl::OString s(tmpBuf.makeStringAndClear());
@@ -67,16 +66,16 @@
 }
 
 
-rtl::OString translateUnoToCppType(
+OString translateUnoToCppType(
     codemaker::UnoType::Sort sort, RTTypeClass typeClass,
-    rtl::OString const & nucleus, bool shortname)
+    OString const & nucleus, bool shortname)
 {
     rtl::OStringBuffer buf;
     if (sort == codemaker::UnoType::SORT_COMPLEX) {
         if (typeClass == RT_TYPE_INTERFACE
             && nucleus == rtl::OString("com/sun/star/uno/XInterface"))
         {
-            buf.append(RTL_CONSTASCII_STRINGPARAM("::com::sun::star::uno::XInterface"));
+            buf.append("::com::sun::star::uno::XInterface");
         } else {
             //TODO: check that nucleus is a valid (UTF-8) identifier
             buf.append(nucleus);
@@ -303,10 +302,7 @@
             || unoIdentifier == "NDEBUG"
             || (forbidden != 0 && unoIdentifier == *forbidden) )
     {
-        rtl::OStringBuffer buf(prefix);
-        buf.append('_');
-        buf.append(unoIdentifier);
-        return buf.makeStringAndClear();
+        return prefix + "_" + unoIdentifier;
     } else {
         return unoIdentifier;
     }
diff --git a/codemaker/source/commonjava/commonjava.cxx b/codemaker/source/commonjava/commonjava.cxx
index 8c01be9..e5f6eca 100644
--- a/codemaker/source/commonjava/commonjava.cxx
+++ b/codemaker/source/commonjava/commonjava.cxx
@@ -39,16 +39,15 @@
 
 namespace codemaker { namespace java {
 
-rtl::OString translateUnoToJavaType(
+OString translateUnoToJavaType(
     codemaker::UnoType::Sort sort, RTTypeClass typeClass,
-    rtl::OString const & nucleus, bool referenceType)
+    OString const & nucleus, bool referenceType)
 {
-    rtl::OStringBuffer buf;
+    OStringBuffer buf;
     if (sort == codemaker::UnoType::SORT_COMPLEX) {
-        if (typeClass == RT_TYPE_INTERFACE
-            && nucleus == rtl::OString("com/sun/star/uno/XInterface"))
+        if (typeClass == RT_TYPE_INTERFACE && nucleus == "com/sun/star/uno/XInterface")
         {
-            buf.append(RTL_CONSTASCII_STRINGPARAM("java/lang/Object"));
+            buf.append("java/lang/Object");
         } else {
             //TODO: check that nucleus is a valid (Java-modified UTF-8)
             // identifier
@@ -145,10 +144,7 @@
         || identifier == "volatile"
         || identifier == "while")
     {
-        rtl::OStringBuffer buf(prefix);
-        buf.append('_');
-        buf.append(identifier);
-        return buf.makeStringAndClear();
+        return prefix + "_" + identifier;
     } else {
         return identifier;
     }
diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx
index 29516c8..6ee5f9e 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -403,13 +403,10 @@
 
     OStringBuffer tmpBuf(length);
 
-    tmpBuf.append("INCLUDED_");
-    tmpBuf.append(m_typeName);
-    tmpBuf.append('_');
+    tmpBuf.append("INCLUDED_" + m_typeName + "_");
     if (bExtended)
     {
-        tmpBuf.append(m_name);
-        tmpBuf.append('_');
+        tmpBuf.append(m_name + "_");
     }
     tmpBuf.append(prefix);
 
@@ -1222,9 +1219,9 @@
     }
 
     if (bResolveTypeOnly) {
-        rtl::OStringBuffer buf;
+        OStringBuffer buf;
         for (sal_Int32 i = 0; i < rank; ++i) {
-            buf.append(RTL_CONSTASCII_STRINGPARAM("[]"));
+            buf.append("[]");
         }
         baseType = buf.makeStringAndClear() + baseType;
     }
@@ -4025,7 +4022,7 @@
                     if ((m_reader.getMethodParameterFlags(i, j) & RT_PARAM_REST)
                         != 0)
                     {
-                        buf.append(RTL_CONSTASCII_STRINGPARAM("[]"));
+                        buf.append("[]");
                     }
                     buf.append(
                         rtl::OUStringToOString(
diff --git a/codemaker/source/javamaker/javatype.cxx b/codemaker/source/javamaker/javatype.cxx
index 404626a..64d0e24 100644
--- a/codemaker/source/javamaker/javatype.cxx
+++ b/codemaker/source/javamaker/javatype.cxx
@@ -63,7 +63,7 @@
 {
     OSL_ASSERT(rank >= 0 && buffer != 0);
     for (sal_Int32 i = 0; i < rank; ++i) {
-        buffer->append(RTL_CONSTASCII_STRINGPARAM("[]"));
+        buffer->append("[]");
     }
     buffer->append(nucleus.replace('/', '.'));
     if (!arguments.empty()) {
@@ -171,20 +171,13 @@
     }
     if (sort == codemaker::UnoType::SORT_COMPLEX) {
         //TODO: check that nucleus is a valid (Java-modified UTF-8) identifier
-        if (typeClass == RT_TYPE_INTERFACE
-            && (nucleus
-                == rtl::OString(
-                    RTL_CONSTASCII_STRINGPARAM("com/sun/star/uno/XInterface"))))
+        if (typeClass == RT_TYPE_INTERFACE && nucleus == "com/sun/star/uno/XInterface")
         {
             if (descriptor != 0) {
-                descriptor->append(
-                    rtl::OString(
-                        RTL_CONSTASCII_STRINGPARAM("Ljava/lang/Object;")));
+                descriptor->append("Ljava/lang/Object;");
             }
             if (signature != 0) {
-                signature->append(
-                    rtl::OString(
-                        RTL_CONSTASCII_STRINGPARAM("Ljava/lang/Object;")));
+                signature->append("Ljava/lang/Object;");
             }
             if (polymorphicUnoType != 0) {
                 polymorphicUnoType->kind = PolymorphicUnoType::KIND_NONE;
@@ -195,13 +188,10 @@
                 dependencies->insert(nucleus);
             }
             if (descriptor != 0) {
-                descriptor->append('L');
-                descriptor->append(nucleus);
-                descriptor->append(';');
+                descriptor->append("L" + nucleus + ";");
             }
             if (signature != 0) {
-                signature->append('L');
-                signature->append(nucleus);
+                signature->append("L" + nucleus);
                 if (!arguments.empty()) {
                     signature->append('<');
                     for (std::vector< rtl::OString >::const_iterator i(
@@ -411,11 +401,9 @@
         polymorphicUnoType);
 }
 
-void MethodDescriptor::addTypeParameter(rtl::OString const & name) {
-    m_descriptorStart.append(RTL_CONSTASCII_STRINGPARAM("Ljava/lang/Object;"));
-    m_signatureStart.append('T');
-    m_signatureStart.append(name);
-    m_signatureStart.append(';');
+void MethodDescriptor::addTypeParameter(OString const & name) {
+    m_descriptorStart.append("Ljava/lang/Object;");
+    m_signatureStart.append("T" + name + ";");
     m_needsSignature = true;
 }
 
@@ -427,9 +415,7 @@
 
 rtl::OString MethodDescriptor::getSignature() const {
     if (m_needsSignature) {
-        rtl::OStringBuffer buf(m_signatureStart);
-        buf.append(m_signatureEnd);
-        return buf.makeStringAndClear();
+        return m_signatureStart + m_signatureEnd;
     } else {
         return rtl::OString();
     }
@@ -756,12 +742,7 @@
     }
     tempfile.close();
     if (!makeValidTypeFile(filename, tempname, check)) {
-        rtl::OStringBuffer msg;
-        msg.append(RTL_CONSTASCII_STRINGPARAM("Cannot create "));
-        msg.append(filename);
-        msg.append(RTL_CONSTASCII_STRINGPARAM(" from temporary file "));
-        msg.append(tempname);
-        throw CannotDumpException(msg.makeStringAndClear());
+        throw CannotDumpException("Cannot create " + filename + " from temporary file " + 
tempname);
     }
 }
 
@@ -1029,13 +1010,8 @@
     SpecialType specialType;
     PolymorphicUnoType polymorphicUnoType;
     if (typeParameterIndex >= 0) {
-        descriptor = rtl::OString(
-            RTL_CONSTASCII_STRINGPARAM("Ljava/lang/Object;"));
-        rtl::OStringBuffer buf;
-        buf.append('T');
-        buf.append(type);
-        buf.append(';');
-        signature = buf.makeStringAndClear();
+        descriptor = "Ljava/lang/Object;";
+        signature = "T" + type + ";";
         specialType = SPECIAL_TYPE_NONE; //TODO: SPECIAL_TYPE_TYPE_PARAMETER?
     } else {
         specialType = getFieldDescriptor(
@@ -1894,26 +1870,21 @@
             if (reader.getReferenceFlags(i) != RT_ACCESS_INVALID
                 || reader.getReferenceSort(i) != RT_REF_TYPE_PARAMETER)
             {
-                throw CannotDumpException(
-                    rtl::OString(
-                        RTL_CONSTASCII_STRINGPARAM("Bad type information")));
+                throw CannotDumpException("Bad type information");
                     //TODO
             }
             rtl::OString name(
                 codemaker::convertString(reader.getReferenceTypeName(i)));
-            buf.append(name);
-            buf.append(RTL_CONSTASCII_STRINGPARAM(":Ljava/lang/Object;"));
+            buf.append(name + ":Ljava/lang/Object;");
             if (!typeParameters.insert(
                     std::map< rtl::OString, sal_Int32 >::value_type(name, i)).
                 second)
             {
-                throw CannotDumpException(
-                    rtl::OString(
-                        RTL_CONSTASCII_STRINGPARAM("Bad type information")));
+                throw CannotDumpException("Bad type information");
                     //TODO
             }
         }
-        buf.append(RTL_CONSTASCII_STRINGPARAM(">Ljava/lang/Object;"));
+        buf.append(">Ljava/lang/Object;");
         sig = buf.makeStringAndClear();
     }
     SAL_WNODEPRECATED_DECLARATIONS_PUSH
@@ -2571,9 +2542,7 @@
             rtl::OString(RTL_CONSTASCII_STRINGPARAM("Bad type information")));
             //TODO
     }
-    rtl::OStringBuffer buf(codemaker::convertString(reader.getTypeName()));
-    buf.append('/');
-    rtl::OString prefix(buf.makeStringAndClear());
+    rtl::OString prefix(codemaker::convertString(reader.getTypeName()) + "/");
     sal_uInt16 fields = reader.getFieldCount();
     for (sal_uInt16 i = 0; i < fields; ++i) {
         rtl::OString className(
@@ -2774,15 +2743,8 @@
         // stack: ex
         code->instrDup();
         // stack: ex ex
-        rtl::OStringBuffer msg;
-        msg.append(
-            RTL_CONSTASCII_STRINGPARAM(
-                "component context fails to supply service "));
-        msg.append(unoName);
-        msg.append(RTL_CONSTASCII_STRINGPARAM(" of type "));
-        msg.append(realJavaBaseName);
-        msg.append(RTL_CONSTASCII_STRINGPARAM(": "));
-        code->loadStringConstant(msg.makeStringAndClear());
+        code->loadStringConstant("component context fails to supply service " + unoName +
+                                 " of type " + realJavaBaseName + ": ");
         // stack: ex ex "..."
         code->loadLocalReference(1);
         // stack: ex ex "..." str
@@ -2957,14 +2919,8 @@
             // stack: ex
             code->instrDup();
             // stack: ex ex
-            rtl::OStringBuffer msg;
-            msg.append(
-                RTL_CONSTASCII_STRINGPARAM(
-                    "component context fails to supply service "));
-            msg.append(unoName);
-            msg.append(RTL_CONSTASCII_STRINGPARAM(" of type "));
-            msg.append(realJavaBaseName);
-            code->loadStringConstant(msg.makeStringAndClear());
+            code->loadStringConstant("component context fails to supply service " + unoName +
+                                     " of type " + realJavaBaseName);
             // stack: ex ex "..."
             code->loadLocalReference(1);
             // stack: ex ex "..." context
@@ -3152,14 +3108,8 @@
     // stack: ex
     code->instrDup();
     // stack: ex ex
-    rtl::OStringBuffer msg;
-    msg.append(
-        RTL_CONSTASCII_STRINGPARAM(
-            "component context fails to supply singleton "));
-    msg.append(unoName);
-    msg.append(RTL_CONSTASCII_STRINGPARAM(" of type "));
-    msg.append(realJavaBaseName);
-    code->loadStringConstant(msg.makeStringAndClear());
+    code->loadStringConstant("component context fails to supply singleton " + unoName +
+                             " of type " + realJavaBaseName);
     // stack: ex ex "..."
     code->loadLocalReference(0);
     // stack: ex ex "..." context

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

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


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.