Changeset 7f3b9d for src/config.cpp


Ignore:
Timestamp:
May 23, 2008, 9:17:19 AM (17 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
040f93
Parents:
6097ea
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
  • src/config.cpp

    r6097ea r7f3b9d  
    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.