[Libreoffice-commits] core.git: 2 commits - connectivity/source include/rtl include/svl sal/rtl sal/util sd/inc sd/source svl/source

Stephan Bergmann sbergman at redhat.com
Tue Feb 18 13:09:23 CET 2014


 connectivity/source/drivers/ado/AColumn.cxx            |    2 
 connectivity/source/drivers/ado/AColumns.cxx           |    2 
 connectivity/source/drivers/ado/AConnection.cxx        |    4 -
 connectivity/source/drivers/ado/APreparedStatement.cxx |    2 
 connectivity/source/drivers/ado/AResultSet.cxx         |    2 
 connectivity/source/drivers/ado/Aolevariant.cxx        |    2 
 connectivity/source/inc/ado/Aolevariant.hxx            |    3 
 include/rtl/string.h                                   |   18 -----
 include/rtl/string.hxx                                 |   15 ----
 include/rtl/ustring.h                                  |   18 -----
 include/rtl/ustring.hxx                                |   15 ----
 include/svl/itemset.hxx                                |    2 
 sal/rtl/strtmpl.cxx                                    |   57 -----------------
 sal/util/sal.map                                       |    6 -
 sd/inc/sdpage.hxx                                      |    2 
 sd/source/core/sdpage2.cxx                             |    4 -
 sd/source/core/stlpool.cxx                             |    2 
 svl/source/items/itemset.cxx                           |    4 -
 18 files changed, 19 insertions(+), 141 deletions(-)

New commits:
commit cd361611ed43b24c2d85dc227ece4f6a5d551104
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Feb 18 13:08:41 2014 +0100

    sal_Bool -> bool fixup in Windows-only ADO driver
    
    Change-Id: I6ad4d730b4b8d715fcab20c09d654e5aa57465d5

diff --git a/connectivity/source/drivers/ado/AColumn.cxx b/connectivity/source/drivers/ado/AColumn.cxx
index 8207916..1e6ab61 100644
--- a/connectivity/source/drivers/ado/AColumn.cxx
+++ b/connectivity/source/drivers/ado/AColumn.cxx
@@ -171,7 +171,7 @@ void OAdoColumn::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& r
                 break;
 
             case PROPERTY_ID_ISAUTOINCREMENT:
-                OTools::putValue( m_aColumn.get_Properties(), OUString( "Autoincrement" ), (sal_Bool)getBOOL( rValue ) );
+                OTools::putValue( m_aColumn.get_Properties(), OUString( "Autoincrement" ), getBOOL( rValue ) );
                 break;
 
             case PROPERTY_ID_IM001:
diff --git a/connectivity/source/drivers/ado/AColumns.cxx b/connectivity/source/drivers/ado/AColumns.cxx
index c7db779..68063f1 100644
--- a/connectivity/source/drivers/ado/AColumns.cxx
+++ b/connectivity/source/drivers/ado/AColumns.cxx
@@ -107,7 +107,7 @@ sdbcx::ObjectType OColumns::appendObject( const OUString&, const Reference< XPro
         WpADOColumn aAddedColumn = m_aCollection.GetItem(OLEVariant(aColumn.get_Name()));
         if ( aAddedColumn.IsValid() )
         {
-            sal_Bool bAutoIncrement = sal_False;
+            bool bAutoIncrement = false;
             pColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)) >>= bAutoIncrement;
             if ( bAutoIncrement )
                 OTools::putValue( aAddedColumn.get_Properties(), OUString("Autoincrement"), bAutoIncrement );
diff --git a/connectivity/source/drivers/ado/AConnection.cxx b/connectivity/source/drivers/ado/AConnection.cxx
index a32ad71..5dc8476 100644
--- a/connectivity/source/drivers/ado/AConnection.cxx
+++ b/connectivity/source/drivers/ado/AConnection.cxx
@@ -138,7 +138,7 @@ void OConnection::construct(const OUString& url,const Sequence< PropertyValue >&
             WpADOProperties aProps = m_pAdoConnection->get_Properties();
             if(aProps.IsValid())
             {
-                OTools::putValue(aProps,OUString("Jet OLEDB:ODBC Parsing"),sal_True);
+                OTools::putValue(aProps,OUString("Jet OLEDB:ODBC Parsing"),true);
                 OLEVariant aVar(OTools::getValue(aProps,OUString("Jet OLEDB:Engine Type")));
                 if(!aVar.isNull() && !aVar.isEmpty())
                     m_nEngineType = aVar;
@@ -208,7 +208,7 @@ OUString SAL_CALL OConnection::nativeSQL( const OUString& _sql ) throw(SQLExcept
     WpADOProperties aProps = m_pAdoConnection->get_Properties();
     if(aProps.IsValid())
     {
-        OTools::putValue(aProps,OUString("Jet OLEDB:ODBC Parsing"),sal_True);
+        OTools::putValue(aProps,OUString("Jet OLEDB:ODBC Parsing"),true);
         WpADOCommand aCommand;
         aCommand.Create();
         aCommand.put_ActiveConnection((IDispatch*)*m_pAdoConnection);
diff --git a/connectivity/source/drivers/ado/APreparedStatement.cxx b/connectivity/source/drivers/ado/APreparedStatement.cxx
index 8b51779..8692726 100644
--- a/connectivity/source/drivers/ado/APreparedStatement.cxx
+++ b/connectivity/source/drivers/ado/APreparedStatement.cxx
@@ -294,7 +294,7 @@ Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery(  ) throw(SQLE
 
 void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException)
 {
-    setParameter(parameterIndex,adBoolean,sizeof(x),x);
+    setParameter(parameterIndex,adBoolean,sizeof(x),bool(x));
 }
 
 void SAL_CALL OPreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
diff --git a/connectivity/source/drivers/ado/AResultSet.cxx b/connectivity/source/drivers/ado/AResultSet.cxx
index 08c2fc8..951f888 100644
--- a/connectivity/source/drivers/ado/AResultSet.cxx
+++ b/connectivity/source/drivers/ado/AResultSet.cxx
@@ -718,7 +718,7 @@ void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException
 
 void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
 {
-    updateValue(columnIndex,x);
+    updateValue(columnIndex,bool(x));
 }
 // -------------------------------------------------------------------------
 void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
diff --git a/connectivity/source/drivers/ado/Aolevariant.cxx b/connectivity/source/drivers/ado/Aolevariant.cxx
index d2a2951..54452bd 100644
--- a/connectivity/source/drivers/ado/Aolevariant.cxx
+++ b/connectivity/source/drivers/ado/Aolevariant.cxx
@@ -113,7 +113,7 @@ OLEVariant::OLEVariant(const OLEVariant& varSrc)
     OSL_UNUSED(eRet);
 }
 
-OLEVariant::OLEVariant(sal_Bool x)              {   VariantInit(this);  vt = VT_BOOL;   boolVal     = (x ? VARIANT_TRUE : VARIANT_FALSE);}
+OLEVariant::OLEVariant(bool x)              {   VariantInit(this);  vt = VT_BOOL;   boolVal     = (x ? VARIANT_TRUE : VARIANT_FALSE);}
 OLEVariant::OLEVariant(sal_Int8 n)              {   VariantInit(this);  vt = VT_I1;     bVal        = n;}
 OLEVariant::OLEVariant(sal_Int16 n)             {   VariantInit(this);  vt = VT_I2;     intVal      = n;}
 OLEVariant::OLEVariant(sal_Int32 n)             {   VariantInit(this);  vt = VT_I4;     lVal        = n;}
diff --git a/connectivity/source/inc/ado/Aolevariant.hxx b/connectivity/source/inc/ado/Aolevariant.hxx
index b25ce19..8efe993 100644
--- a/connectivity/source/inc/ado/Aolevariant.hxx
+++ b/connectivity/source/inc/ado/Aolevariant.hxx
@@ -76,7 +76,8 @@ namespace connectivity
             OLEVariant();
             OLEVariant(const VARIANT& varSrc);
             OLEVariant(const OLEVariant& varSrc)    ;
-            OLEVariant(sal_Bool x)  ;
+            OLEVariant(bool x)  ;
+            OLEVariant(sal_Bool) SAL_DELETED_FUNCTION;
             OLEVariant(sal_Int8 n)  ;
             OLEVariant(sal_Int16 n) ;
             OLEVariant(sal_Int32 n) ;
commit 042725a5dadc9f2c6368ca451b6d20046129b8af
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Feb 18 12:49:50 2014 +0100

    Stick to a single O[U]String hash function
    
    8f8bc0dcf3bc253ae49159d52db049767f476ced "Move string hash function into String
    class" had introduced a new getHash64 that, besides returning sal_uInt64 instead
    of just sal_Int32, didn't do sampling of only a handful of characters, but
    always computed the hash over all characters (as the usage in SfxItemSet and
    SdPage appears to require for either performance or approximated correctness).
    
    However, it would be advantageous to keep the stable URE interface as small as
    possible.  Now, O(1) sampling was apparently considered state of the art when
    the rtl string classes were first created, closely copying java.lang.String,
    which at that time demanded sampling for hashCode(), too---but never sampling
    more than 15 characters, with the obvious (in hindsight, at least) performance
    catastrophes, so they changed it to O(n) somewhere along the way.
    
    Based on that, this commit changes the existing hash functions to not do
    sampling any more, and removes the newly introduced -64 variants again.  (Where
    the extended value range of sal_uInt64 compared to sal_Int32 was hopefully not
    vital to the existing uses.)
    
    The old implementation used sampling only for strings of length >= 256, so I did
    a "make check" build with an instrumented hash function that flagged all uses
    with inputs of length >= 256, and grepped workdir/{Cppunit,Junit,Python}Test for
    hits.  Of the 2849 hits encountered, 2845 where in the range from 256 to 295
    characters, and only the remaining four where of 2472 characters.  Those four
    were from CppunitTest_sc_subsequent_filters_test, importing long text into a
    cell, causing ScDocumentImport::setStringCell to call
    svl::SharedStringPool::intern, which internally uses an unordered_set.  These
    results appear to justify the change.
    
    Change-Id: I78fcc3b0f07389bdf36a21701b95a1ff0a0d970f

diff --git a/include/rtl/string.h b/include/rtl/string.h
index 71e0955..32344bf 100644
--- a/include/rtl/string.h
+++ b/include/rtl/string.h
@@ -277,24 +277,6 @@ SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_hashCode(
 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_hashCode_WithLength(
         const sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
 
-/** Return a hash code (64bit) for a string.
-
-    It is not allowed to store the hash code persistently, because later
-    versions could return other hash codes.
-
-    @param str
-    a string.  Need not be null-terminated, but must be at least as long as
-    the specified len.
-
-    @param len
-    the length of the string.
-
-    @return
-    a hash code for the given string.
- */
-SAL_DLLPUBLIC sal_uInt64 SAL_CALL rtl_str_hashCode64_WithLength(
-        const sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
-
 /** Search for the first occurrence of a character within a string.
 
     The string must be null-terminated.
diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
index 5eb4fcf..fb7283b 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -892,21 +892,6 @@ public:
     }
 
     /**
-      Returns a 64bit hash of the string data.
-      This hashes the entire data, while hashCode would do sampling for larger string sizes.
-
-      @return   a hash code value of the string data
-
-      @see hashCode() for simple hashes
-
-      @since LibreOffice 4.3
-    */
-    sal_uInt64 hashCode64() const SAL_THROW(())
-    {
-        return rtl_str_hashCode64_WithLength( pData->buffer, pData->length );
-    }
-
-    /**
       Returns a hashcode for this string.
 
       @return   a hash code value for this object.
diff --git a/include/rtl/ustring.h b/include/rtl/ustring.h
index 2069899..80c6bcc 100644
--- a/include/rtl/ustring.h
+++ b/include/rtl/ustring.h
@@ -551,24 +551,6 @@ SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_hashCode(
 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_hashCode_WithLength(
         const sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
 
-/** Return a hash code (64bit) for a string.
-
-    It is not allowed to store the hash code persistently, because later
-    versions could return other hash codes.
-
-    @param str
-    a string.  Need not be null-terminated, but must be at least as long as
-    the specified len.
-
-    @param len
-    the length of the string.
-
-    @return
-    a hash code for the given string.
- */
-SAL_DLLPUBLIC sal_uInt64 SAL_CALL rtl_ustr_hashCode64_WithLength(
-        const sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
-
 /** Search for the first occurrence of a character within a string.
 
     The string must be null-terminated.
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index 9f9a956..f1a5f4a 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -1227,21 +1227,6 @@ public:
     }
 
     /**
-      Returns a 64bit hash of the string data.
-      This hashes the entire data, while hashCode would do sampling for larger string sizes.
-
-      @return   a hash code value of the string data
-
-      @see hashCode() for simple hashes
-
-      @since LibreOffice 4.3
-    */
-    sal_uInt64 hashCode64() const SAL_THROW(())
-    {
-        return rtl_ustr_hashCode64_WithLength( pData->buffer, pData->length );
-    }
-
-    /**
       Returns a hashcode for this string.
 
       @return   a hash code value for this object.
diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx
index 2284281..b1a00c7 100644
--- a/include/svl/itemset.hxx
+++ b/include/svl/itemset.hxx
@@ -144,7 +144,7 @@ public:
     virtual SvStream &          Store( SvStream &, bool bDirect = false ) const;
 
     bool                        operator==(const SfxItemSet &) const;
-    virtual sal_uInt64          getHash() const;
+    sal_Int32                   getHash() const;
     virtual OString             stringify() const;
 };
 
diff --git a/sal/rtl/strtmpl.cxx b/sal/rtl/strtmpl.cxx
index a9eb665..9576096 100644
--- a/sal/rtl/strtmpl.cxx
+++ b/sal/rtl/strtmpl.cxx
@@ -252,68 +252,17 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( hashCode )( const IMPL_RTL_STRCODE* pStr )
 
 /* ----------------------------------------------------------------------- */
 
-sal_uInt64 SAL_CALL IMPL_RTL_STRNAME( hashCode64_WithLength )( const IMPL_RTL_STRCODE* pStr,
-                                                               sal_Int32 nLen )
-    SAL_THROW_EXTERN_C()
-{
-    sal_uInt64 nHash = 0;
-
-    for( sal_Int32 i = 0; i < nLen; i++ )
-        nHash = (nHash << 5) - nHash + *pStr++;
-    return nHash;
-}
-
-/* ----------------------------------------------------------------------- */
-
 sal_Int32 SAL_CALL IMPL_RTL_STRNAME( hashCode_WithLength )( const IMPL_RTL_STRCODE* pStr,
                                                             sal_Int32 nLen )
     SAL_THROW_EXTERN_C()
 {
     sal_uInt32 h = static_cast<sal_uInt32>(nLen);
-
-    if ( nLen < 256 )
-    {
-        while ( nLen > 0 )
-        {
-            h = (h*37U) + IMPL_RTL_USTRCODE( *pStr );
-            pStr++;
-            nLen--;
-        }
-    }
-    else
+    while ( nLen > 0 )
     {
-        sal_Int32               nSkip;
-        const IMPL_RTL_STRCODE* pEndStr = pStr+nLen-5;
-
-        /* only sample some characters */
-        /* the first 3, some characters between, and the last 5 */
-        h = (h*39U) + IMPL_RTL_USTRCODE( *pStr );
-        pStr++;
-        h = (h*39U) + IMPL_RTL_USTRCODE( *pStr );
-        pStr++;
-        h = (h*39U) + IMPL_RTL_USTRCODE( *pStr );
+        h = (h*37U) + IMPL_RTL_USTRCODE( *pStr );
         pStr++;
-
-        nSkip = nLen / 8;
-        nLen -= 8;
-        while ( nLen > 0 )
-        {
-            h = (h*39U) + IMPL_RTL_USTRCODE( *pStr );
-            pStr += nSkip;
-            nLen -= nSkip;
-        }
-
-        h = (h*39U) + IMPL_RTL_USTRCODE( *pEndStr );
-        pEndStr++;
-        h = (h*39U) + IMPL_RTL_USTRCODE( *pEndStr );
-        pEndStr++;
-        h = (h*39U) + IMPL_RTL_USTRCODE( *pEndStr );
-        pEndStr++;
-        h = (h*39U) + IMPL_RTL_USTRCODE( *pEndStr );
-        pEndStr++;
-        h = (h*39U) + IMPL_RTL_USTRCODE( *pEndStr );
+        nLen--;
     }
-
     return static_cast<sal_Int32>(h);
 }
 
diff --git a/sal/util/sal.map b/sal/util/sal.map
index 074eb7b..1456d6d 100644
--- a/sal/util/sal.map
+++ b/sal/util/sal.map
@@ -670,12 +670,6 @@ LIBO_UDK_4.2 { # symbols available in >= LibO 4.2
         rtl_ustr_toUInt32;
 } LIBO_UDK_4.1;
 
-LIBO_UDK_4.3 { #symbols available in >= LibO 4.3
-    global:
-         rtl_str_hashCode64_WithLength;
-         rtl_ustr_hashCode64_WithLength;
-} LIBO_UDK_4.2;
-
 PRIVATE_1.0 {
     global:
         osl_detail_ObjectRegistry_storeAddresses;
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
index c08b48f..40a4dcf 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -378,7 +378,7 @@ public:
     void removeAnnotation( const ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation );
     const sd::AnnotationVector& getAnnotations() const { return maAnnotations; }
     bool hasAnnotations() const { return !maAnnotations.empty(); }
-    sal_uInt64 getHash() const;
+    sal_Int32 getHash() const;
     virtual OString stringify() const;
 
 
diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
index a870895..3f56150 100644
--- a/sd/source/core/sdpage2.cxx
+++ b/sd/source/core/sdpage2.cxx
@@ -603,9 +603,9 @@ OString SdPage::stringify() const
     return aString.makeStringAndClear();
 }
 
-sal_uInt64 SdPage::getHash() const
+sal_Int32 SdPage::getHash() const
 {
-    return stringify().hashCode64();
+    return stringify().hashCode();
 }
 
 
diff --git a/sd/source/core/stlpool.cxx b/sd/source/core/stlpool.cxx
index b1bad09..387fb8f 100644
--- a/sd/source/core/stlpool.cxx
+++ b/sd/source/core/stlpool.cxx
@@ -650,7 +650,7 @@ void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily
             SfxStyleSheetBase* pExistingSheet = Find(aName, eFamily);
             if( pExistingSheet && !rRenameSuffix.isEmpty() )
             {
-                sal_uInt64 nHash = xSheet->GetItemSet().getHash();
+                sal_Int32 nHash = xSheet->GetItemSet().getHash();
                 if( pExistingSheet->GetItemSet().getHash() != nHash )
                 {
                     OUString aTmpName = aName + rRenameSuffix;
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 0a4e301..d68655f 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -2032,9 +2032,9 @@ SfxItemSet *SfxAllItemSet::Clone(sal_Bool bItems, SfxItemPool *pToPool ) const
 
 // -----------------------------------------------------------------------
 
-sal_uInt64 SfxItemSet::getHash() const
+sal_Int32 SfxItemSet::getHash() const
 {
-    return stringify().hashCode64();
+    return stringify().hashCode();
 }
 
 // -----------------------------------------------------------------------


More information about the Libreoffice-commits mailing list