summaryrefslogtreecommitdiffstats
path: root/src/htmlgen.cpp
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2014-10-23 18:33:19 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2014-10-23 18:33:19 (GMT)
commit43edc14cd357dcb070402bccc5030507570c22a4 (patch)
tree05c76a0026b6d1fabe1c3967b041e38b9550f9f7 /src/htmlgen.cpp
parent151876a8321204bd2ec08ec6c4de38ba9fb2d034 (diff)
downloadDoxygen-43edc14cd357dcb070402bccc5030507570c22a4.zip
Doxygen-43edc14cd357dcb070402bccc5030507570c22a4.tar.gz
Doxygen-43edc14cd357dcb070402bccc5030507570c22a4.tar.bz2
Introduce new optimized string implementation (attempt 2)
Diffstat (limited to 'src/htmlgen.cpp')
-rw-r--r--src/htmlgen.cpp43
1 files changed, 6 insertions, 37 deletions
diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp
index 62ae1c7..b459446 100644
--- a/src/htmlgen.cpp
+++ b/src/htmlgen.cpp
@@ -912,40 +912,6 @@ static void writeServerSearchBox(FTextStream &t,const char *relPath,bool highlig
//------------------------------------------------------------------------
-/// substitute all occurrences of \a src in \a s by \a dst
-QCString substitute(const char *s,const char *src,const char *dst)
-{
- if (s==0 || src==0) return s;
- const char *p, *q;
- int srcLen = qstrlen(src);
- int dstLen = dst ? qstrlen(dst) : 0;
- int resLen;
- if (srcLen!=dstLen)
- {
- int count;
- for (count=0, p=s; (q=strstr(p,src))!=0; p=q+srcLen) count++;
- resLen = (int)(p-s)+qstrlen(p)+count*(dstLen-srcLen);
- }
- else // result has same size as s
- {
- resLen = qstrlen(s);
- }
- QCString result(resLen+1);
- char *r;
- for (r=result.data(), p=s; (q=strstr(p,src))!=0; p=q+srcLen)
- {
- int l = (int)(q-p);
- memcpy(r,p,l);
- r+=l;
- if (dst) memcpy(r,dst,dstLen);
- r+=dstLen;
- }
- qstrcpy(r,p);
- //printf("substitute(%s,%s,%s)->%s\n",s,src,dst,result.data());
- return result;
-}
-//----------------------------------------------------------------------
-
/// Clear a text block \a s from \a begin to \a end markers
QCString clearBlock(const char *s,const char *begin,const char *end)
{
@@ -989,6 +955,7 @@ QCString clearBlock(const char *s,const char *begin,const char *end)
QCString selectBlock(const QCString& s,const QCString &name,bool enable)
{
+ // TODO: this is an expensive function that is called a lot -> optimize it
const QCString begin = "<!--BEGIN " + name + "-->";
const QCString end = "<!--END " + name + "-->";
const QCString nobegin = "<!--BEGIN !" + name + "-->";
@@ -1341,9 +1308,11 @@ void HtmlCodeGenerator::writeLineNumber(const char *ref,const char *filename,
const char *anchor,int l)
{
if (!m_streamSet) return;
- QCString lineNumber,lineAnchor;
- lineNumber.sprintf("%5d",l);
- lineAnchor.sprintf("l%05d",l);
+ const int maxLineNrStr = 10;
+ char lineNumber[maxLineNrStr];
+ char lineAnchor[maxLineNrStr];
+ snprintf(lineNumber,maxLineNrStr,"%5d",l);
+ snprintf(lineAnchor,maxLineNrStr,"l%05d",l);
m_t << "<div class=\"line\">";
m_t << "<a name=\"" << lineAnchor << "\"></a><span class=\"lineno\">";