[Coin-discuss] Small patch for OsiMsk

Geoff Leyland geoff_leyland at fastmail.fm
Wed Mar 9 22:05:13 EST 2016


Hi,

OsiMskSolverInterface.cpp contains this function:

static inline void
checkMSKerror( int err, std::string mskfuncname, std::string osimethod )
{
  if( err != MSK_RES_OK )
  {
    char s[100];
    sprintf( s, "%s returned error %d", mskfuncname.c_str(), err );
    std::cout << "ERROR: " << s << " (" << osimethod << 
    " in OsiMskSolverInterface)" << std::endl;
    throw CoinError( s, osimethod.c_str(), "OsiMskSolverInterface" );
  }
}

>From every callsite in the file, it is called with const char * arguments.  std::strings are constructed from these const char *s which are then used as, you guessed it, const char *s through c_str().  As far as I can tell, with the standard "make", these constructor calls are not optimised out.

I have inherited a code which runs many thousands of small LPs, and spends about as much time constructing problems as solving them.  Changing the definition of checkMSKerror to:

static inline void
checkMSKerror( int err, const char *mskfuncname, const char *osimethod )

and removing the c_str()s pretty much halves the construction time, and saves about 30s on a 3-minute run.

Would anyone with permissions be interested in committing such a patch?  Or can I send a pull request from the github mirror - I'm assuming that's read-only?


Cheers,
Geoff




More information about the Coin-discuss mailing list