Skip to content

Commit

Permalink
QEdidParser: optimize the hardcoded EDID vendor table
Browse files Browse the repository at this point in the history
Instead of using an array of fixed-length strings for the vendor names,
use qOffsetStringArray instead. This removes the need of using the
longest vendor name length as the size of the fixed-length strings,
which results in a massive waste of space. This saves 150KB of
(readonly) data.

Details: there are 2555 entries, each one hardcoded to be 78 byte long,
for a total of 199290 bytes. However the vendor names themselves amount
only to 50658 bytes.

Making all this data optional on desktop Linux (where the vendor data is
present anyhow on the system, in /usr/share/) is left for a future
change.

Change-Id: I17007865e741e3dab15dd2ab2feffbce4664fb37
Reviewed-by: Volker Hilsheimer <[email protected]>
  • Loading branch information
dangelog committed Dec 20, 2024
1 parent 8d0283a commit 6844c70
Show file tree
Hide file tree
Showing 3 changed files with 7,746 additions and 2,493 deletions.
8 changes: 4 additions & 4 deletions src/gui/util/qedidparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,20 @@ bool QEdidParser::parse(const QByteArray &blob)

if (manufacturer.isEmpty()) {
// Find the manufacturer from the vendor lookup table
const auto compareVendorId = [](const VendorTable &vendor, const char *str)
const auto compareVendorId = [](const QEdidVendorId &vendor, const char *str)
{
return strncmp(vendor.id, str, 3) < 0;
};

const auto b = std::begin(q_edidVendorTable);
const auto e = std::end(q_edidVendorTable);
const auto b = std::begin(q_edidVendorIds);
const auto e = std::end(q_edidVendorIds);
auto it = std::lower_bound(b,
e,
pnpId,
compareVendorId);

if (it != e && strncmp(it->id, pnpId, 3) == 0)
manufacturer = QString::fromUtf8(it->name);
manufacturer = QString::fromUtf8(q_edidVendorNames + q_edidVendorNamesOffsets[it - b]);
}

// If we don't know the manufacturer, fallback to PNP ID
Expand Down
Loading

0 comments on commit 6844c70

Please sign in to comment.