move copy constructor for json_data

オープン
#979 コメント 1 件 リアクション 0 件 担当者 1 名 GitHub で見る

@mitzimorris がすでに取り組んでいます。

2019年7月4日 から。

評価

この issue はまだ評価されていません。

説明

Summary:

As json_data is being used in CmdStan, it does this:

    stan::json::json_data d(stream);
    stream.close();
    std::shared_ptr<stan::io::var_context> result
      = std::make_shared<stan::json::json_data>(d);
    return result;

The class json_data is a subclass of var_context. It does not define a copy constructor, so the default copy constructor will be invoked by that call to make_shared (which constructs an object and returns a shared pointer to it that encapsulates the memory management). That means a deep copy of all the data. That means all the data sits in memory twice while this block is executing.

To solve this problem, we need to define move semantics so that the returned object constructed in the shared pointer can steal the data from the local object.

I'm not sure how to test this as we want to make sure we reduce total dynamic memory overhead requirements.

Current Version:

v2.19.1

主要言語
C++
スター
240
フォーク
105
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

stan-dev/cmdstan のほかの issue

stan-dev/cmdstan の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。