summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2013-10-19 16:22:43 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2013-10-19 16:22:43 (GMT)
commitcebd28148d8e6ea77d180ef1e186df7993d9e413 (patch)
tree3b9459f418d12d10a9120f878372adf4b32ebd88 /src
parenteea006ad6f63083782a3decda51b6bf80caa47af (diff)
downloadpowder-cebd28148d8e6ea77d180ef1e186df7993d9e413.zip
powder-cebd28148d8e6ea77d180ef1e186df7993d9e413.tar.gz
Minute performance improvement for Sign.getText
Diffstat (limited to 'src')
-rw-r--r--src/simulation/Sign.cpp45
1 files changed, 26 insertions, 19 deletions
diff --git a/src/simulation/Sign.cpp b/src/simulation/Sign.cpp
index 57a8a0d..b6a18cc 100644
--- a/src/simulation/Sign.cpp
+++ b/src/simulation/Sign.cpp
@@ -17,30 +17,37 @@ std::string sign::getText(Simulation *sim)
char signText[256];
sprintf(signText, "%s", text.substr(0, 255).c_str());
- if (!strcmp(signText,"{p}"))
+ if(signText[0] && signText[0] == '{')
{
- float pressure = 0.0f;
- if (x>=0 && x<XRES && y>=0 && y<YRES)
- pressure = sim->pv[y/CELL][x/CELL];
- sprintf(buff, "Pressure: %3.2f", pressure); //...pressure
- }
- else if (!strcmp(signText,"{t}"))
- {
- if (x>=0 && x<XRES && y>=0 && y<YRES && sim->pmap[y][x])
- sprintf(buff, "Temp: %4.2f", sim->parts[sim->pmap[y][x]>>8].temp-273.15); //...temperature
+ if (!strcmp(signText,"{p}"))
+ {
+ float pressure = 0.0f;
+ if (x>=0 && x<XRES && y>=0 && y<YRES)
+ pressure = sim->pv[y/CELL][x/CELL];
+ sprintf(buff, "Pressure: %3.2f", pressure); //...pressure
+ }
+ else if (!strcmp(signText,"{t}"))
+ {
+ if (x>=0 && x<XRES && y>=0 && y<YRES && sim->pmap[y][x])
+ sprintf(buff, "Temp: %4.2f", sim->parts[sim->pmap[y][x]>>8].temp-273.15); //...temperature
+ else
+ sprintf(buff, "Temp: 0.00"); //...temperature
+ }
else
- sprintf(buff, "Temp: 0.00"); //...temperature
+ {
+ int pos=splitsign(signText);
+ if (pos)
+ {
+ strcpy(buff, signText+pos+1);
+ buff[strlen(signText)-pos-2]=0;
+ }
+ else
+ strcpy(buff, signText);
+ }
}
else
{
- int pos=splitsign(signText);
- if (pos)
- {
- strcpy(buff, signText+pos+1);
- buff[strlen(signText)-pos-2]=0;
- }
- else
- strcpy(buff, signText);
+ strcpy(buff, signText);
}
return std::string(buff);