diff options
author | Ahmad Samir <[email protected]> | 2025-07-01 20:07:42 +0300 |
---|---|---|
committer | Ahmad Samir <[email protected]> | 2025-07-02 03:51:15 +0300 |
commit | 23441921a5e0b7e92bc42def8664fc2cfc7b7c5f (patch) | |
tree | ab3df1bc907dab4f4e353ac80c016adf0311ab53 /src | |
parent | 21f3364c06f9ea03be7c29de90b4fbf9eb26425b (diff) |
"detaching" in the old name is confusing. Also add a comment about
the rationale of the method, that should be helpful when (re)reading
this code in the future.
Pointed out in code review.
Amends 2075459bcf2c13b94a954fca6fa541de1cb1fcd0.
Change-Id: I41dba6d38d93bc595740b97da7b84d6f38d6a222
Reviewed-by: Marc Mutz <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/text/qstringalgorithms_p.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/corelib/text/qstringalgorithms_p.h b/src/corelib/text/qstringalgorithms_p.h index a017ec58d49..c873858c59b 100644 --- a/src/corelib/text/qstringalgorithms_p.h +++ b/src/corelib/text/qstringalgorithms_p.h @@ -149,7 +149,10 @@ template <typename StringType> struct QStringAlgorithms return src.size() + adjust; } - static inline void replace_detaching(StringType &src, qsizetype bsize, + // Instead of detaching, i.e. copying the whole data array then performing the + // replacement, create a new buffer, copy `src` and `after` to it and swap it + // with `src`. + static inline void replace_into_copy(StringType &src, qsizetype bsize, ViewType after, QSpan<const qsizetype> indices, qsizetype newlen) { @@ -237,7 +240,7 @@ template <typename StringType> struct QStringAlgorithms // Instead of detaching (which would copy the whole data array) then // performing the replacement, allocate a new string and copy the data // over from `src` and `after` as needed. - replace_detaching(src, bsize, after, indices, newlen); + replace_into_copy(src, bsize, after, indices, newlen); return; } |