Commit Graph
23 Commits
Author SHA1 Message Date
Noel Grandin ec1c4c4930 O[U]String::replaceAt overloads that take string_view
which results in lots of nice string_view improvements picked up by the
plugins

Change-Id: Ib0ec3887816b3d4436d003b739d9814f83e244b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125657
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-11-23 14:00:08 +01:00
Noel Grandin a4fafab70d improve the comments of the number conversion functions
For the
    rtl_str_to<NumberType>_WithLength
category of functions, the string does not need to be null-terminated

Change-Id: I1971c8c10b760743633523e6f680366eafdfc685
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119325
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-07-21 18:50:43 +02:00
Stephan Bergmann 99a1290b3f Use existing rtl_math_stringToDouble
...like it is also already done in LineParser::readDouble in
sdext/source/pdfimport/wrapper/wrapper.cxx (esp. since the code should be
changed to use C++17 std::from_chars once that is available in all our
baselines), reverting again the introduction of rtl_str_toDouble_WithLength in
b1df9c6734 "[API CHANGE] reduce cost of numeric
conversion"

Change-Id: If7e3a15649f80093d3407157412fd3deb3a38b12
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119318
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Jenkins
2021-07-21 15:38:03 +02:00
Stephan Bergmann 9230c189eb Use existing rtl_str_toInt64_WithLength
...like it is also already done in LineParser::readInt32 in
sdext/source/pdfimport/wrapper/wrapper.cxx (esp. since the code should be
changed to use C++17 std::from_chars once that is available in all our
baselines), reverting again the introduction of rtl_str_toInt32_WithLength in
b1df9c6734 "[API CHANGE] reduce cost of numeric
conversion"

Change-Id: I2789f8ec55c8d89150d1c68e6b353a1d2e1d1703
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119301
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Jenkins
2021-07-21 13:20:18 +02:00
Noel Grandin b1df9c6734 [API CHANGE] reduce cost of numeric conversion
on a hot path, since we already know the length of these strings.

Which requires adding some new variants of our string conversion
functions

Change-Id: I1877f8f3c72934c07f14eec7e73bbe8d7b0f1808
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119065
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-07-17 09:12:26 +02:00
Stephan Bergmann eca89ece45 Replace rtl_string_getTokenView with o3tl::getToken
...to not needlessly extend the sal ABI.

At least for now, o3tl::getToken has a simpler interface than its
OString::getToken counterpart (driven mainly by how it is used for now): it does
not support a `token` argument, and its `position` argument must not be npos.
To meet the latter requirement, the check for "subpath" in LineParser::readPath
has been reworked slightly.

Change-Id: I4428fe2d9aa03ca83a436fc6493fbc34665a8033
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115742
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-05-18 16:10:41 +02:00
Noel Grandin 7462343cb9 update "add OString::getTokenView"
update
    commit 3669d4ec43
    Date:   Fri May 14 15:51:38 2021 +0200
    add OString::getTokenView (tdf#42374 related)
with suggested changes from gerrit review

Change-Id: I861d960deaa010740a4aa964e402c4c76a85cbc7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115706
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-05-18 12:58:55 +02:00
Noel Grandin 3669d4ec43 add OString::getTokenView (tdf#42374 related)
small improvement to PDF import

no need to construct temporary string objects when we are just to
going to convert them into int/double.
So use a view and convert the data through the view.

Change-Id: I824fe88bf17142b48fe6032e10c0f3a111927e96
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115616
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-05-15 11:21:59 +02:00
msrijita18 b1fb6338cf tdf#130978 Added comment to all published API
Change-Id: I744788bde9778f85ccd9d7667e19d16842900a29
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110248
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-02-02 20:56:27 +01:00
Julien Nabet 04203a2675 Replace remaining uses of sal_Char
+ remove sal_Char check on compilerplugins
Change-Id: I0f7da14e620f0c3d031d038aa8345ba4080fb3e9

Change-Id: Ia6dba4f27b47bc9e0c89159182ad80a5aee17166
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102499
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-09-12 13:36:42 +02:00
Noel Grandin ab35d2ded1 tdf#125688 speed up load of change-tracking ODS
by 10%, by avoiding an OUString construction in a hot path
through
  XMLTextColumnContext_Impl::XMLTextColumnContext_Impl
  -> sax::Convert::convertNumber

Also changed XMLTextAnimationStepPropertyHdl::importXML
to take advantage of the modified convertNumber passing
convention.

Change-Id: I4e5503dbb094c88a09af8b6dc8c22b6c53f9eb75
Reviewed-on: https://gerrit.libreoffice.org/81726
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-10-31 07:02:09 +01:00
Andrea Gelmini a4f99585a8 Fix typo
Change-Id: I0974986301548cc5cd95dd40403bef0a5a7dd90d
Reviewed-on: https://gerrit.libreoffice.org/75770
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2019-07-17 18:22:08 +02:00
Noel Grandin 2f3684b228 [API CHANGE] add some more asserts to the string functions
rtl_[u]String_alloc now requires that the length be >= 0.
Since this function is only @since Libreoffice 4.1, it is unlikely
to be widely used externally.

Removed some unit tests that were testing invalid or out of
range paramers, which are already not allowed according to the
documented contract of those functions.

The change in writerfilter is because the new asserts triggered
when running testFdo74745

The change in SwTextNode::EraseText is because testFdo60842
triggered the assert in replaceAt.

The change in SwFieldSlot::SwFieldSlot is because
testMoveRange::Import_Export_Import triggered the assert in
replaceAt.

The changes in SwFieldSlot::SwFieldSlot and TabControl::ImplGetItemSize
are due to failures in the uitests.

Change-Id: Ib317261067649b0de96df12873ce31360cd24681
Reviewed-on: https://gerrit.libreoffice.org/58390
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-08-02 11:07:55 +02:00
Stephan Bergmann 697f01e052 SAL_W32 is just an alias for _WIN32
...so consistently use the latter instead of the former

Change-Id: I144d5e7c472632f93b2258461510346bc85892d9
Reviewed-on: https://gerrit.libreoffice.org/48135
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-01-19 08:19:38 +01:00
Stephan Bergmann 189abcf0db loplugin:includeform: UNO API include files
Change these back to consistently use the "..." form to include other UNO API
include files, for the benefit of external users of this API.

Change-Id: I9c9188e895eb3495e20a71ad44abfa2f6061fa94
2017-10-23 22:22:50 +02:00
Tor Lillqvist 0c2dc8ed10 RTL_UNICODETOTEXT_FLAGS_NOCOMPOSITE has never had any effect
Change-Id: I9004ec2229cd31fb899b23c8ce59f5fd49ac03a2
2014-04-23 11:25:43 +03:00
Stephan Bergmann 042725a5da Stick to a single O[U]String hash function
8f8bc0dcf3 "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
2014-02-18 13:08:58 +01:00
Muthu Subramanian 8f8bc0dcf3 Move string hash function into String class.
hashCode() seems to do sampling while creating the hash.
hashCode64() will not.

Change-Id: Id30f5a2a774cf5244dbc00da9649e95a532484be
2014-02-13 13:13:53 +05:30
Norbert Thiebaud 1b9742b7d7 fdo#65108 inter-module includes <> include/rtl
Change-Id: Ic90a365a237aa23846f97131146a5aa2c46b5fd2
2013-11-09 18:48:41 -06:00
Thomas Arnhold 1130a359cb fixincludeguards.sh: include - the rest
Change-Id: If1ee11da444a7f96f2d8668b277540da0bb4dbe9
2013-10-23 23:22:31 +02:00
Stephan Bergmann 3af0114a29 Introduce O[U]String::toUInt32
...which has become necessary since bd60d41176
"Handle oveflow in O(U)String::toInt() functions" reduces values in the range
(SAL_MAX_INT32 .. SAL_MAX_UINT32] to zero, but some calls of toInt32(16) relied
on getting a correct (unsigned) value for the whole input range ["0" ..
"FFFFFFFF"] (see libreoffice-4-1 commit 9bf6c83367cedb7be81bf67f30d2147d26c7a8c3
"Revert overflow checks in O[U]String::toInt{32,64} again").

Audited all uses of toInt32/64 with non-decimal radix.  (There is still a TODO
comment in oox/source/helper/attributelist.cxx, and
stoc/source/typeconv/convert.cxx will still need some love and test code.)

Change-Id: Iadaca1c0e41dab553687d0ce41c20c10cd657a95
2013-06-13 17:08:36 +02:00
Tor Lillqvist cb6d67c21f Spelling "separate" (etc) correctly is hard 2013-05-15 11:14:28 +03:00
David Tardon 6c7659b584 move URE headers to include/
Change-Id: Ib48a12e902f2311c295b2007f08f44dee28f431d
Reviewed-on: https://gerrit.libreoffice.org/3499
Reviewed-by: David Tardon <dtardon@redhat.com>
Tested-by: David Tardon <dtardon@redhat.com>
2013-04-24 05:17:10 +00:00