PHANTOM
🇮🇳 IN
Skip to content

[News] Use interned strings for fast comparisons in feed building#34191

Open
zenparsing wants to merge 1 commit intomasterfrom
ksmith-news-perf-3
Open

[News] Use interned strings for fast comparisons in feed building#34191
zenparsing wants to merge 1 commit intomasterfrom
ksmith-news-perf-3

Conversation

@zenparsing
Copy link
Collaborator

Introduces a NameTable for interning publisher IDs and channel names, replacing string comparisons with integer comparisons during feed generation. Publisher-to-channel mappings are computed once and reused.

Subtask of brave/brave-browser#48969

const std::vector<mojom::Signal*>& signals,
NameId publisher_id,
absl::flat_hash_set<NameId> channels,
const bool& discoverable) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: const bool& is less efficient than passing bool by value — prefer bool directly. best practice

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


std::string NameTable::GetString(NameId id) const {
if (!id) {
return "";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: prefer std::optional<std::string> over empty string as a sentinel value — it makes the "no value" case explicit. best practice

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Introduces a NameTable for interning publisher IDs and channel names,
replacing string comparisons with integer comparisons during feed
generation. Publisher-to-channel mappings are computed once and reused.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants