Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9316 in orxonox.OLD


Ignore:
Timestamp:
Jul 18, 2006, 2:19:52 AM (18 years ago)
Author:
bensch
Message:

faster substring

Location:
branches/proxy/src/lib/util
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/util/executor/executor_functional.h

    r8271 r9316  
    179179  {
    180180    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    181       fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) );
     181      (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])));
    182182  };
    183183
     
    222222  {
    223223    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    224       fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)),
    225       fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)));
     224      (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])),
     225      (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1])));
    226226  };
    227227
     
    276276  {
    277277    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    278       fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)),
    279       fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)),
    280       fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)));
     278      (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])),
     279      (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1])),
     280      (sub.size() > 2) ? fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)) : (fromMulti<type2>(this->defaultValue[2])));
    281281  };
    282282
     
    333333  {
    334334    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    335       fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)),
    336       fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)),
    337       fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)),
    338       fromString<type3>(sub[3], getDefault<type3>(this->defaultValue, 3)));
     335      (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])),
     336      (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1])),
     337      (sub.size() > 2) ? fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)) : (fromMulti<type2>(this->defaultValue[2])),
     338      (sub.size() > 3) ? fromString<type3>(sub[3], getDefault<type3>(this->defaultValue, 3)) : (fromMulti<type3>(this->defaultValue[3])));
    339339  };
    340340
     
    392392  {
    393393    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    394       fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)),
    395       fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)),
    396       fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)),
    397       fromString<type3>(sub[3], getDefault<type3>(this->defaultValue, 3)),
    398       fromString<type4>(sub[4], getDefault<type4>(this->defaultValue, 4)));
     394      (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])),
     395      (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1])),
     396      (sub.size() > 2) ? fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)) : (fromMulti<type2>(this->defaultValue[2])),
     397      (sub.size() > 3) ? fromString<type3>(sub[3], getDefault<type3>(this->defaultValue, 3)) : (fromMulti<type3>(this->defaultValue[3])),
     398      (sub.size() > 4) ? fromString<type4>(sub[4], getDefault<type4>(this->defaultValue, 4)) : (fromMulti<type4>(this->defaultValue[4])));
    399399  };
    400400
  • branches/proxy/src/lib/util/substring.cc

    r9313 r9316  
    104104
    105105/** @brief An empty String */
    106 const std::string SubString::emptyString = "";
     106// const std::string SubString::emptyString = "";
    107107/** @brief Helper that gets you a String consisting of all White Spaces */
    108108const std::string SubString::WhiteSpaces = " \n\t";
     
    234234  }
    235235  else
    236     return SubString::emptyString;
     236  {
     237    static std::string empty;
     238    return empty;
     239  }
    237240}
    238241
  • branches/proxy/src/lib/util/substring.h

    r9314 r9316  
    8484  inline unsigned int size() const { return this->strings.size(); };
    8585  /** @param i the i'th String @returns the i'th string from the subset of Strings */
    86   inline const std::string& operator[](unsigned int i) const { return (i < this->strings.size()) ? this->strings[i] : emptyString; };
     86  inline const std::string& operator[](unsigned int i) const { return /*(i < this->strings.size()) ? */this->strings[i] /*: emptyString*/; };
    8787  /** @param i the i'th String @returns the i'th string from the subset of Strings */
    8888  inline const std::string& getString(unsigned int i) const { return (*this)[i]; };
     
    114114  std::vector<std::string>  strings;                      //!< strings produced from a single string splitted in multiple strings
    115115
    116   static const std::string emptyString;
     116//   static const std::string emptyString;
    117117};
    118118
Note: See TracChangeset for help on using the changeset viewer.