Skip to content

JSONRPC: replace std::string with std::string_view when registring a new endpoint.#8916

Merged
brbzull0 merged 1 commit intoapache:10-Devfrom
brbzull0:rpc-registration-use-string-view
Jun 16, 2022
Merged

JSONRPC: replace std::string with std::string_view when registring a new endpoint.#8916
brbzull0 merged 1 commit intoapache:10-Devfrom
brbzull0:rpc-registration-use-string-view

Conversation

@brbzull0
Copy link
Contributor

1 - Use std::string_view in the RPC manager class to avoid possible extra heap allocation when registring a new endpoint.
2 - Fix typo.

…xtra heap allocation when registring a new endpoint.
@brbzull0 brbzull0 added the JSONRPC JSONRPC 2.0 related work. label Jun 15, 2022
@brbzull0 brbzull0 added this to the 10-Dev milestone Jun 15, 2022
@brbzull0 brbzull0 self-assigned this Jun 15, 2022
Copy link
Contributor

@bneradt bneradt left a comment

Choose a reason for hiding this comment

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

Looks fine.

@SolidWallOfCode
Copy link
Member

Looking at this -

return _handlers.emplace(name, std::move(call)).second;

What is the type of the name in the object? Does it persist after the string view goes out of scope?

@SolidWallOfCode SolidWallOfCode self-requested a review June 15, 2022 15:41
@brbzull0
Copy link
Contributor Author

Looking at this -

return _handlers.emplace(name, std::move(call)).second;

What is the type of the name in the object? Does it persist after the string view goes out of scope?

It does:

std::unordered_map<std::string, InternalHandler> _handlers; ///< Registered handler container.

std::string

@brbzull0 brbzull0 merged commit a82875c into apache:10-Dev Jun 16, 2022
@zwoop zwoop modified the milestones: 10-Dev, 10.0.0 Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

JSONRPC JSONRPC 2.0 related work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants