diff options
| author | Marc Mutz <marc.mutz@qt.io> | 2025-08-26 19:10:45 +0200 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2025-08-29 02:03:40 +0200 |
| commit | 44da6f996a6d687caa2d1692e4b6125f330ee3e5 (patch) | |
| tree | 7d737b9166535217b3ee59b0df8977a34479969b /src/widgets/doc/snippets/widgetdelegate.cpp | |
| parent | 3bf21f41a2bd0dbc4653d3a4b75c1556de32bcc4 (diff) | |
util/unicode: Extract Method readUnicodeFile()
There's about a dozen files this program reads, and in each of these
cases, the code to read the file line-by-line, remove comments (or
just LF) and trim the line before further handling is duplicated. It's
also very inefficient, we have better APIs these days (readLineInto(),
rvalue *this overloads, truncate() instead of = left(), ...). Besides,
as Mårten pointed out in review, trimmed() already removes the LF, so
we don't need to do it manually.
So Extract Method readUnicodeFile() that does that, coroutine-style
(but with function object for now), from all the readX() functions
(except readUnicodeData() itself, which is using nested readLine()s.
Also maintain a line number for later improving the error messages.
Remove some isEmpty() checks in the lambdas that, after the
refactoring, can never be true (because removing whitespace from a
trimmed() string cannot make the string empty, ditto with
simplified()).
The extracted function could even pre-split the line along `;`, but
for that, I would port each lambda to use QByteArrayView / qTokenizer
first.
Picking to all active branches, because a) this is a tool and b) we
continue to update the Unicode tables in all active branches, so the
tool to do so should not differ, unless the target branch requires it
(changed data structures, e.g.). Note that readLineInto() is not in
6.5, but the tool is not required to be built against the Qt version
it is building tables for, so we can use the latest Qt features here.
Pick-to: 6.10 6.9 6.8 6.5
Change-Id: I3b699f213c98baa45bc8bbdb7ae2ac985d893798
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Diffstat (limited to 'src/widgets/doc/snippets/widgetdelegate.cpp')
0 files changed, 0 insertions, 0 deletions
