Ignore:
Timestamp:
Jun 25, 2014 1:32:56 AM (10 years ago)
Author:
ldelgass
Message:

Use local string vars instead of temporaries

Location:
trunk/packages/vizservers
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/geovis/RenderServer.cpp

    r4349 r4424  
    7474        << " {" << ((view.getSRS() == NULL) ? "" : view.getSRS()->getVertInitString()) << "}"
    7575        << "\n";
    76     len = oss.str().size();
    77 #ifdef USE_THREADS
    78     queueResponse(oss.str().c_str(), len, Response::VOLATILE);
     76    std::string ostr = oss.str();
     77    len = ostr.size();
     78#ifdef USE_THREADS
     79    queueResponse(ostr.c_str(), len, Response::VOLATILE);
    7980#else
    80     ssize_t bytesWritten = SocketWrite(oss.str().c_str(), len);
     81    ssize_t bytesWritten = SocketWrite(ostr.c_str(), len);
    8182
    8283    if (bytesWritten < 0) {
     
    169170{
    170171    std::ostringstream oss;
    171     oss << "nv>ok -token " << g_stats.nCommands <<  "\n";
    172     int nBytes = oss.str().length();
     172    oss << "nv>ok -token " << g_stats.nCommands << "\n";
     173    std::string ostr = oss.str();
     174    int nBytes = ostr.length();
    173175
    174176    TRACE("Sending OK for commands through %lu", g_stats.nCommands);
    175177#ifdef USE_THREADS
    176     queueResponse(oss.str().c_str(), nBytes, Response::VOLATILE, Response::OK);
    177 #else
    178     if (write(g_fdOut, oss.str().c_str(), nBytes) < 0) {
     178    queueResponse(ostr.c_str(), nBytes, Response::VOLATILE, Response::OK);
     179#else
     180    if (write(g_fdOut, ostr.c_str(), nBytes) < 0) {
    179181        ERROR("write failed: %s", strerror(errno));
    180182        return -1;
  • trunk/packages/vizservers/geovis/RendererCmd.cpp

    r4422 r4424  
    176176        << " {" << ((view.getSRS() == NULL) ? "" : view.getSRS()->getVertInitString()) << "}"
    177177        << "\n";
    178     len = oss.str().size();
     178    std::string ostr = oss.str();
     179    len = ostr.size();
    179180#ifdef USE_THREADS
    180     queueResponse(oss.str().c_str(), len, Response::VOLATILE);
     181    queueResponse(ostr.c_str(), len, Response::VOLATILE);
    181182#else
    182     ssize_t bytesWritten = SocketWrite(oss.str().c_str(), len);
     183    ssize_t bytesWritten = SocketWrite(ostr.c_str(), len);
    183184
    184185    if (bytesWritten < 0) {
     
    11871188        std::ostringstream path;
    11881189        path << "/tmp/tmp" << getpid() << ".earth";
    1189         FILE *tmpFile = fopen(path.str().c_str(), "w");
     1190        const char *pathStr = path.str().c_str();
     1191        FILE *tmpFile = fopen(pathStr, "w");
    11901192        fwrite(buf, len, 1, tmpFile);
    11911193        fclose(tmpFile);
    1192         g_renderer->loadEarthFile(path.str().c_str());
    1193         unlink(path.str().c_str());
     1194        g_renderer->loadEarthFile(pathStr);
     1195        unlink(pathStr);
    11941196        free(buf);
    11951197    } else {
     
    18441846            std::ostringstream oss;
    18451847            oss << "nv>viserror -type internal_error -token " << g_stats.nCommands << " -bytes " << nBytes << "\n" << string;
    1846             nBytes = oss.str().length();
    1847 
    1848             if (queueResponse(oss.str().c_str(), nBytes, Response::VOLATILE, Response::ERROR) < 0) {
     1848            std::string ostr = oss.str();
     1849            nBytes = ostr.length();
     1850
     1851            if (queueResponse(ostr.c_str(), nBytes, Response::VOLATILE, Response::ERROR) < 0) {
    18491852                return -1;
    18501853            }
  • trunk/packages/vizservers/geovis/Stats.cpp

    r4349 r4424  
    101101
    102102    int fd = getStatsFile();
    103     int result = writeToStatsFile(fd, oss.str().c_str(),
    104                                   oss.str().length());
     103    std::string ostr = oss.str();
     104    int result = writeToStatsFile(fd, ostr.c_str(), ostr.length());
    105105    close(fd);
    106106    return result;
     
    121121    keyStream << key << " "
    122122              << getpid();
    123 
    124     TRACE("Stats file key: '%s'", keyStream.str().c_str());
     123    std::string keystr = keyStream.str();
     124    TRACE("Stats file key: '%s'", keystr.c_str());
    125125
    126126    md5_init(&state);
    127     md5_append(&state, (const md5_byte_t *)keyStream.str().c_str(), keyStream.str().length());
     127    md5_append(&state, (const md5_byte_t *)keystr.c_str(), keystr.length());
    128128    md5_finish(&state, digest);
    129129    for (int i = 0; i < 16; i++) {
  • trunk/packages/vizservers/nanovis/Command.cpp

    r4422 r4424  
    23022302            std::ostringstream oss;
    23032303            oss << "nv>viserror -type internal_error -token " << g_stats.nCommands << " -bytes " << nBytes << "\n" << string;
    2304             nBytes = oss.str().length();
     2304            std::string ostr = oss.str();
     2305            nBytes = ostr.length();
    23052306
    23062307#ifdef USE_THREADS
    2307             queueResponse(oss.str().c_str(), nBytes, Response::VOLATILE, Response::ERROR);
     2308            queueResponse(ostr.c_str(), nBytes, Response::VOLATILE, Response::ERROR);
    23082309#else
    23092310            if (write(fdOut, oss.str().c_str(), nBytes) < 0) {
Note: See TracChangeset for help on using the changeset viewer.