Unverified Commit 5f86bac4 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer Committed by GitHub
Browse files

Merge pull request #2144 from rbberger/tokenizer-performance-fixes

Performance optimization of Tokenizer
parents fc9bbd4d 3c99471d
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -1123,7 +1123,7 @@ char * EIMPotentialFileReader::next_line(FILE * fp) {
      concat = false;
      concat = false;
    }
    }


    nwords = utils::count_words(line);
    nwords += utils::count_words(&line[n]);


    // skip line if blank
    // skip line if blank
    if (nwords > 0) {
    if (nwords > 0) {
+4 −4
Original line number Original line Diff line number Diff line
@@ -2448,11 +2448,11 @@ int AtomVec::process_fields(char *str, const char *default_str, Method *method)
  }
  }


  // tokenize words in both strings
  // tokenize words in both strings
  Tokenizer words(str, " ");
  std::vector<std::string> words = Tokenizer(str, " ").as_vector();
  Tokenizer def_words(default_str, " ");
  std::vector<std::string> def_words = Tokenizer(default_str, " ").as_vector();


  int nfield = words.count();
  int nfield = words.size();
  int ndef   = def_words.count();
  int ndef   = def_words.size();


  // process fields one by one, add to index vector
  // process fields one by one, add to index vector


+2 −2
Original line number Original line Diff line number Diff line
@@ -514,8 +514,8 @@ char *AtomVecHybrid::merge_fields(int inum, char *root,


  // identify unique words in concatenated string
  // identify unique words in concatenated string


  Tokenizer words(concat, " ");
  std::vector<std::string> words = Tokenizer(concat, " ").as_vector();
  int nwords = words.count();
  int nwords = words.size();


  int *unique = new int[nwords];
  int *unique = new int[nwords];


+2 −2
Original line number Original line Diff line number Diff line
@@ -83,9 +83,9 @@ void PotentialFileReader::next_dvector(double * list, int n) {
  }
  }
}
}


ValueTokenizer PotentialFileReader::next_values(int nparams, const std::string & seperators) {
ValueTokenizer PotentialFileReader::next_values(int nparams, const std::string & separators) {
  try {
  try {
    return reader->next_values(nparams, seperators);
    return reader->next_values(nparams, separators);
  } catch (FileReaderException & e) {
  } catch (FileReaderException & e) {
    error->one(FLERR, e.what());
    error->one(FLERR, e.what());
  }
  }
+1 −1
Original line number Original line Diff line number Diff line
@@ -43,7 +43,7 @@ namespace LAMMPS_NS
    void skip_line();
    void skip_line();
    char * next_line(int nparams = 0);
    char * next_line(int nparams = 0);
    void next_dvector(double * list, int n);
    void next_dvector(double * list, int n);
    ValueTokenizer next_values(int nparams, const std::string & seperators = TOKENIZER_DEFAULT_SEPERATORS);
    ValueTokenizer next_values(int nparams, const std::string & separators = TOKENIZER_DEFAULT_SEPARATORS);


    // convenience functions
    // convenience functions
    double next_double();
    double next_double();
Loading