[Libreoffice-commits] core.git: include/rtl
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Mon Mar 15 08:26:03 UTC 2021
include/rtl/stringconcat.hxx | 2 +-
include/rtl/ustrbuf.hxx | 1 -
include/rtl/ustring.hxx | 1 -
3 files changed, 1 insertion(+), 3 deletions(-)
New commits:
commit 5d83d14ef8e3a149f2dbcddc18a70edda021fbfe
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Mar 12 16:04:19 2021 +0100
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Mon Mar 15 09:25:27 2021 +0100
Clarify that rtl::ToStringHelper::length must be precise
d87f5d30879aca73fff271c254589fc41a91fdd0 "support for fast O(U)String
concatenation using operator+", introducing rtl::ToStringHelper, had intended
that length can return an optimistic maximum value if the exact value cannot be
determined (e.g., when creating the textual representation of a numerical value
only on the fly, not upfront), witness the comments removed now, but never made
use of that, always returning precise values from the various
rtl::ToStringHelper::length specializations.
And then cbe3b2fe0b9d745e22a2bf436ce55141b15f9502 "Avoid conversion warning in
O[U]String[Buffer] constructors", not being aware that length could
theoretically return an imprecise value, made certain code rely on it always
returning a precise value.
So clarify the status quo, that length always returns a precise value. (See
also the discussion in the comments of abandoned
<https://gerrit.libreoffice.org/c/core/+/110129> "Drop obsolete comments".)
Change-Id: I7dc72e9e15304779cc4d2edc01331959b6fbe869
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112397
Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
Tested-by: Jenkins
diff --git a/include/rtl/stringconcat.hxx b/include/rtl/stringconcat.hxx
index 7f55d6c3473d..554fdd3f4403 100644
--- a/include/rtl/stringconcat.hxx
+++ b/include/rtl/stringconcat.hxx
@@ -59,7 +59,7 @@ Helper class for converting a given type to a string representation.
template< typename T >
struct ToStringHelper
{
- /// Return length of the string representation of the given object (if not known exactly, it needs to be the maximum).
+ /// Return length of the string representation of the given object.
static std::size_t length( const T& );
/// Add 8-bit representation of the given object to the given buffer and return position right after the added data.
static char* addData( char* buffer, const T& ) SAL_RETURNS_NONNULL;
diff --git a/include/rtl/ustrbuf.hxx b/include/rtl/ustrbuf.hxx
index f1f2521a8ae5..170b76908dff 100644
--- a/include/rtl/ustrbuf.hxx
+++ b/include/rtl/ustrbuf.hxx
@@ -239,7 +239,6 @@ public:
sal_Unicode* end = c.addData( pData->buffer );
*end = '\0';
pData->length = l;
- // TODO realloc in case pData->>length is noticeably smaller than l ?
}
/**
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index 597a56832ad5..bb3390c19985 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -457,7 +457,6 @@ public:
sal_Unicode* end = c.addData( pData->buffer );
pData->length = l;
*end = '\0';
- // TODO realloc in case pData->length is noticeably smaller than l?
}
}
More information about the Libreoffice-commits
mailing list