move copy constructor for json_data

Aberta
#979 1 comentário 0 reações 1 responsável Ver no GitHub

@mitzimorris já está trabalhando nisso.

Desde 4/7/2019.

Avaliação

Esta issue ainda não foi avaliada.

Descrição

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

Linguagem predominante
C++
Estrelas
240
Forks
105
Merge médio
1d 5h
PRs com merge (30d)
1

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de stan-dev/cmdstan

Todas as issues de stan-dev/cmdstan

Issues semelhantes

Mais issues de C++

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.