Ignore:
Timestamp:
Feb 26, 2008, 3:24:46 PM (13 years ago)
Author:
Jari Häkkinen
Message:

Improved memory usage of BaseFileConverter?. Previous implementation was not flattering.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/se/lu/thep/wenni/base/base1/BaseFileConverter/BaseFileConverter.cc

    r95 r594  
    33/*
    44  Copyright (C) 2005, 2006 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2008 Jari Häkkinen
    56
    67  This file is part of WeNNI,
     
    8485  }
    8586
    86   // Convert assayFields to GSL-matrices
    87   std::vector<theplu::wenni::Data> data;
     87  std::vector<theplu::wenni::Data*> data;
    8888  std::vector<theplu::wenni::Clone> clone;
    8989  for (int i=0; i<option.nof_property(); i++) {
    9090    if (option.type(i)=="-assayFields")
    91       data.push_back(theplu::wenni::Data(bfs,option.property(i),
    92                                         option.output_file(i)));
     91      data.push_back(new theplu::wenni::Data(bfs,option.property(i),
     92                                            option.output_file(i)));
    9393    else if (option.type(i)=="-columns")
    9494      clone.push_back(theplu::wenni::Clone(bfs,option.property(i),
     
    103103  // Extract data
    104104  if (data.size()) {
    105     std::vector<std::string> vals(data[0].total_nof_columns());
     105    std::vector<std::string> vals(data[0]->total_nof_columns());
    106106    while (bfr.readVec(vals))
    107107      for (size_t i=0; i<data.size(); i++)
    108         data[i].push_back(vals);
     108        data[i]->write(vals);
    109109  }
    110110
     
    116116        clone[i].push_back(vals);
    117117  }
    118 
    119   for (size_t i=0; i<data.size(); i++)
    120     data[i].write_matrix();
    121118  for (size_t i=0; i<clone.size(); i++)
    122119    clone[i].write();
    123120
     121  // clean up
     122  for (size_t i=0; i<data.size(); i++)
     123    delete data[i];
     124
    124125  return 0;
    125126}
Note: See TracChangeset for help on using the changeset viewer.