Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: compiled/filter/ActiveFilter.cpp

Issue 29404594: Noissue - [emscripten] Replace sprintf() usage by safe alternatives (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Implemented a simple number conversion method Created April 6, 2017, 3:12 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « compiled/bindings.ipp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiled/filter/ActiveFilter.cpp
===================================================================
--- a/compiled/filter/ActiveFilter.cpp
+++ b/compiled/filter/ActiveFilter.cpp
@@ -18,27 +18,16 @@
#include <cstdio>
#include "ActiveFilter.h"
#include "../StringScanner.h"
namespace
{
const DependentString DEFAULT_DOMAIN(u""_str);
-
- OwnedString to_string(unsigned int i)
- {
- char buffer[11];
- int len = sprintf(buffer, "%u", i);
-
- OwnedString result(len);
- for (String::size_type i = 0; i < len; i++)
- result[i] = buffer[i];
- return result;
- }
}
ActiveFilter::ActiveFilter(Type type, const String& text, bool ignoreTrailingDot)
: Filter(type, text), mDisabled(false), mHitCount(0), mLastHit(0),
mIgnoreTrailingDot(ignoreTrailingDot)
{
}
@@ -189,19 +178,19 @@ OwnedString ActiveFilter::Serialize() co
{
/* TODO this is very inefficient */
OwnedString result(Filter::Serialize());
if (mDisabled)
result.append(u"disabled=true\n"_str);
if (mHitCount)
{
result.append(u"hitCount="_str);
- result.append(to_string(mHitCount));
+ result.append(mHitCount);
result.append(u'\n');
}
if (mLastHit)
{
result.append(u"lastHit="_str);
- result.append(to_string(mLastHit));
+ result.append(mLastHit);
result.append(u'\n');
}
return result;
}
« no previous file with comments | « compiled/bindings.ipp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld