[hxcommon] CR: nptime.cpp change
Alan Li alanli at real.comhi, this patch is not for a bug fix, instead it is supposed to be an
alternative implementation with the following two considerations:
1. it tries to eliminate "%f" conversion in vsnprintf because it is not
needed and in some platforms vsnprintf(.. "%f", ) is not as reliable as
vsnprintf(..."%d"..) (such as Openwave one).
2 it eliminates the double float division to calculate the sub seconds by
using vsnprintf format flag "06d", which is possible because the variable
m_lMicroSecond is within 1000000
As a background info, this change is purely triggered by Openwave porting
that has the rtsp PLAY message's parameter range converted incorrectly due
the floating point arithmetics (%f) not fully supported in Openwave sdk, but
if this change is reasonably sound and useful, then this will improve the
performance of the code as well as its portability a little bit in general.
alan,
? dbgsim
? relsim
? cutil_diff.txt
? Umakefil.upp
? Makefile
? comutilnptime_diff.txt
Index: nptime.cpp
===================================================================
RCS file: /cvs/common/util/nptime.cpp,v
retrieving revision 1.4
diff -u -1 -0 -r1.4 nptime.cpp
--- nptime.cpp 1 May 2003 16:15:41 -0000 1.4
+++ nptime.cpp 15 Jul 2003 01:37:41 -0000
@@ -195,26 +195,25 @@
{
m_lSecond = mSec / 1000;
m_lMicroSecond = (mSec % 1000) * 1000;
normalize();
}
const char*
NPTime::toString()
{
char strBuf[80]; /* Flawfinder: ignore */
+const INT32 MSECS_PER_SEC = 1000;
if(m_lMicroSecond > 0)
{
- double dSeconds = m_lSecond +
- ((double)m_lMicroSecond / USECS_PER_SEC);
- SafeSprintf(strBuf, sizeof(strBuf), "%f", dSeconds);
+ SafeSprintf(strBuf, sizeof(strBuf), "%ld.%06d", m_lSecond,
m_lMicroSecond);
}
else
{
SafeSprintf(strBuf, sizeof(strBuf), "%ld", m_lSecond);
}
m_asString = strBuf;
return m_asString;
}
void
------------------------------------------------------------------------------------------
Alan Li, Technical Lead,
RealNetworks, Inc. Email: alanli at real.com
2601 Elliott Avenue Phone: (206)892-6032
Seattle, WA 98121 http://www.realnetworks.com
------------------------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe at common.helixcommunity.org
For additional commands, e-mail: dev-help at common.helixcommunity.org