office-gobmx/writerperfect
Mike Kaganski 8a017d25a6 Avoid COW overhead using css::uno::Sequence
The scenarios are:

1. Calling sequence's begin() and end() in pairs to pass to algorithms
   (both calls use getArray(), which does the COW checks)
2. In addition to #1, calling end() again when checking result of find
   algorithms, and/or begin() to calculate result's distance
3. Using non-const sequences in range-based for loops, which internally
   do #1
4. Assigning sequence to another sequence variable, and then modifying
   one of them

In many cases, the sequences could be made const, or treated as const
for the purposes of the algorithms (using std::as_const, std::cbegin,
and std::cend). Where algorithm modifies the sequence, it was changed
to only call getArray() once. For that, css::uno::toNonConstRange was
introduced, which returns a struct (sublclass of std::pair) with two
iterators [begin, end], that are calculated using one call to begin()
and one call to getLength().

To handle #4, css::uno::Sequence::swap was introduced, that swaps the
internal pointer to uno_Sequence. So when a local Sequence variable
should be assigned to another variable, and the latter will be modified
further, it's now possible to use swap instead, so the two sequences
are kept independent.

The modified places were found by temporarily removing non-const end().

Change-Id: I8fe2787f200eecb70744e8b77fbdf7a49653f628
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123542
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-10-14 06:00:49 +02:00
..
inc
qa
source
uiconfig/ui
AllLangMoTarget_wpt.mk
CppunitTest_writerperfect_calc.mk
CppunitTest_writerperfect_dialogs_test.mk
CppunitTest_writerperfect_draw.mk
CppunitTest_writerperfect_epubexport.mk
CppunitTest_writerperfect_import.mk
CppunitTest_writerperfect_impress.mk
CppunitTest_writerperfect_stream.mk
CppunitTest_writerperfect_wpftimport.mk
CppunitTest_writerperfect_writer.mk
IwyuFilter_writerperfect.yaml
Library_wpftcalc.mk
Library_wpftdraw.mk
Library_wpftimpress.mk
Library_wpftqahelper.mk
Library_wpftwriter.mk
Library_writerperfect.mk
Makefile
Module_writerperfect.mk
README.md
UIConfig_writerperfect.mk
UITest_writerperfect_epubexport.mk

Import / Export Filters for WordPerfect and Other Formats

Contains import / export filters for WordPerfect and other formats, wrappers for a set of similar libraries.

This collection of filters is here in this folder in addition to the WordPerfect filter that gave the module its (humorous) name "writerperfect" because the libraries they use all have the same "style" of API and are developed, at least partially, by the same person or group of persons.