Ignore:
Timestamp:
May 23, 2008, 9:17:19 AM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
6145aa7
Parents:
6c96f4
Message:

Lots of for loops now count in reverse order where it does not matter, some 3 -> NDIM

for(i=0;i<var;i++) is slower than for (i=var;i--;) if the order of the i's is not important (note: i-- is also a value and it stops when on i == 0 automatically)
in builder.cpp there were some remnant 3 actually meant to be NDIM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified molecuilder/src/config.cpp

    r6c96f4 rf75030  
    282282        case 'j': // BoxLength
    283283          cout << Verbose(0) << "enter lower triadiagonalo form of basis matrix" << endl << endl;
    284           for (int i=0;i<6;i++) {
     284          for (int i=6;i--;) {
    285285            cout << Verbose(0) << "Cell size" << i << ": ";
    286286            cin >> mol->cell_size[i];
     
    408408
    409409/** Retrieves the path in the given config file name.
    410  * \param *filename config file string
     410 * \param filename config file string
    411411 */
    412 void config::RetrieveConfigPathAndName(char *filename)
     412void config::RetrieveConfigPathAndName(string filename)
    413413{
    414414  char *ptr = NULL;
     415  char *buffer = new char[MAXSTRINGSIZE];
     416  strncpy(buffer, filename.c_str(), MAXSTRINGSIZE);
    415417  int last = -1;
    416   for(int i=0;i<MAXSTRINGSIZE;i++) {
    417     if (filename[i] == '/')
    418       last = i;
    419     if (filename[i] == '\0')
     418  for(last=MAXSTRINGSIZE;last--;) {
     419    if (buffer[last] == '/')
    420420      break;
    421421  }
    422   if (last == -1) { // no path in front, set to local directory.
     422  if (last == 0) { // no path in front, set to local directory.
    423423    strcpy(configpath, "./");
    424     ptr = filename;
     424    ptr = buffer;
    425425  } else {
    426     strncpy(configpath, filename, last+1);
    427     ptr = &filename[last+1];
     426    strncpy(configpath, buffer, last+1);
     427    ptr = &buffer[last+1];
    428428    if (last < 254)
    429429      configpath[last+1]='\0';
     
    431431  strcpy(configname, ptr);
    432432  cout << "Found configpath: " << configpath << ", dir slash was found at " << last << ", config name is " << configname << "." << endl;
     433  delete[](buffer);
    433434};
    434435
     
    824825 
    825826 
    826   for (i=0;i<128;i++) elementhash[i] = NULL;
     827  for (i=MAX_ELEMENTS;i--;)
     828    elementhash[i] = NULL;
    827829  cout << Verbose(0) << "Parsing Ions ..." << endl;
    828830  No=0;
Note: See TracChangeset for help on using the changeset viewer.