NerixyzandGitHub 8f84483330 feat: improve memory usage of FFZ badges (#7126)
FFZ badges consume a decent amount of memory in Chatterino. Before this
PR, they consumed 18.4 MiB.

We can do two cheap optimizations that cut the use in half:
- Use [`QVarLengthArray`](https://doc.qt.io/qt-6/qvarlengtharray.html)
to store the badges for a user instead of `std::set`. `std::set` always
allocates, even if there's only one badge. Since most users only have
one, we create many small allocations. With `QVarLengthArray<T, N>`, `N`
elements are stored inline. This reduced the memory usage to 11.9 MiB.
- Use `boost::unordered_flat_map` instead of `std::unordered_map`.
Because of relaxed requirements for the Boost map, it doesn't need to
store as much auxiliary data. This reduced the memory usage to 9.3 MiB.

A further optimization could be the use of a
`boost::container::flat_multimap<std::string, int>`. This gets us to 4.6
MiB. I haven't measured the performance of this. We'd have to assume
that FFZ returns us unique users per badge. The comparison with
`QString` for the lookup can be done by comparing `QString <
QLatin1StringView` (as we know badge IDs are latin1).


Reviewed-by: pajlada <rasmus.karlsson@pajlada.com>
2026-07-25 15:30:52 +00:00
2026-04-07 18:21:07 +00:00
2026-03-22 12:50:28 +01:00
2026-01-02 14:56:29 +00:00
2017-10-13 21:57:43 +02:00

chatterinoLogo Chatterino 2 GitHub Actions Build (Windows, Ubuntu, MacOS) Build FreeBSD Chocolatey Package Flatpak Package

Chatterino 2 is a chat client for Twitch.tv. The Chatterino 2 wiki can be found here. Contribution guidelines can be found here.

Download

Current releases are available at https://chatterino.com. Windows users can also install Chatterino from Chocolatey.

Nightly build

You can download the latest Chatterino 2 build over here

You might also need to install the VC++ Redistributables from Microsoft if you do not have it installed already.
If you still receive an error about MSVCR120.dll missing, then you should install the VC++ 2013 Restributable.

Building

To get source code with required submodules run:

git clone --recurse-submodules https://github.com/Chatterino/chatterino2.git

or

git clone https://github.com/Chatterino/chatterino2.git
cd chatterino2
git submodule update --init --recursive

Git blame

This project has big commits in the history which touch most files while only doing stylistic changes. To improve the output of git-blame, consider setting:

git config blame.ignoreRevsFile .git-blame-ignore-revs

This will ignore all revisions mentioned in the .git-blame-ignore-revs file. GitHub does this by default.

Code style

The code is formatted using clang-format. Our configuration is found in the .clang-format file in the repository root directory.

For more contribution guidelines, take a look at the wiki.

Doxygen

Doxygen is used to generate project information daily and is available here.

Languages
C++ 95%
CMake 2.5%
Python 1.2%
Lua 0.7%
Shell 0.3%
Other 0.2%