KEMBAR78
Suppress copy by wx257osn2 · Pull Request #6 · faithandbrave/life_string_view · GitHub
Skip to content

Conversation

wx257osn2
Copy link
Contributor

  • std::shared_ptr<void> のコピーコストを踏み倒すために
    • コンストラクタで std::move を使用
      • 引数が値渡しなのでmoveで良い
    • 方々で値渡しではなくconst lvalue-refで受けるように変更
      • こっちはライブラリの方向性的にどうかな…とも思ったんですが,(ユーザーの使い方はさておき)ライブラリ側で引数で受ける分にはconst lvalue-refで受けた方が良いのかなと思っています(寿命延長されない場合とかありますかね…?ありそうならこっちのコミットは消します)

@faithandbrave faithandbrave merged commit 3720f94 into faithandbrave:main Jul 16, 2024
@faithandbrave
Copy link
Owner

ありがとうございます。shared_ptrのコピーでは参照カウントの追加コストが発生するので、const参照で受け取るほうがいいですね。

@wx257osn2 wx257osn2 deleted the suppress-copy branch July 16, 2024 06:17
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