Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<xstring>: conversion between basic_string specializations could sometimes memcpy #2901

Closed
CaseyCarter opened this issue Jul 23, 2022 · 0 comments · Fixed by #4073
Closed
Labels
fixed Something works now, yay! performance Must go faster

Comments

@CaseyCarter
Copy link
Contributor

For example:

std::u8string x = "potato";
std::string a(x.begin(), x.end());
std::string b(x.data(), x.size());
std::string c(std::from_range, x);

could all be implemented with memcpy. At the very least, this should happen when initializing std::basic_string<char, std::char_traits<char>> from std::basic_string<T, std::char_traits<T>> when T is an integral type with size 1. More generally, I think this optimization could apply when the source and target element types are integral types of the same size and the target traits type is library-provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed Something works now, yay! performance Must go faster
Projects
None yet
2 participants