move copy constructor for json_data

未关闭
#979 1 条评论 0 个 reaction 已指派 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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

stan-dev/cmdstan 的其他 Issue

查看 stan-dev/cmdstan 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。