More constness in SafeBuf

This commit is contained in:
Ivan Skytte Jørgensen
2016-10-03 15:03:35 +02:00
parent 57c1ac9122
commit 9a8631664b
2 changed files with 10 additions and 8 deletions

@ -1572,7 +1572,7 @@ bool SafeBuf::printTimeAgo ( int32_t ago , int32_t now , bool shorthand ) {
return true;
}
bool SafeBuf::hasDigits() {
bool SafeBuf::hasDigits() const {
if ( m_length <= 0 ) return false;
for ( int32_t i = 0 ; i < m_length ; i++ )
if ( is_digit(m_buf[i]) ) return true;
@ -1580,10 +1580,12 @@ bool SafeBuf::hasDigits() {
}
int32_t SafeBuf::indexOf(char c) {
char* p = m_buf;
char* pend = m_buf + m_length;
while (p < pend && *p != c) p++;
if (p == pend) return -1;
int32_t SafeBuf::indexOf(char c) const {
const char *p = m_buf;
const char *pend = m_buf + m_length;
while (p < pend && *p != c)
p++;
if(p == pend)
return -1;
return p - m_buf;
}

@ -164,7 +164,7 @@ public:
bool brify( const char *s, int32_t slen, int32_t cols, const char *sep = "<br>",
bool isHtml = true );
bool hasDigits();
bool hasDigits() const;
// . like "1 minute ago" "5 hours ago" "3 days ago" etc.
// . "ts" is the delta-t in seconds
@ -221,7 +221,7 @@ public:
return true;
}
int32_t indexOf(char c);
int32_t indexOf(char c) const;
bool safeCdataMemcpy(const char *s, int32_t len);
bool pushChar (char i) {