Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: tools/skimage_main.cpp

Issue 646213002: Eliminate one copy of replace_char() function. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: bad... Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/skimage_main.cpp
diff --git a/tools/skimage_main.cpp b/tools/skimage_main.cpp
index 7a1954a07237b61afdb5eceb3bee88276e865ef5..7be2c4d9b110c019cdd02ac80d06b29ae22d2552 100644
--- a/tools/skimage_main.cpp
+++ b/tools/skimage_main.cpp
@@ -464,24 +464,6 @@ static void test_stream_without_length(const char srcPath[], SkImageDecoder* cod
}
#endif // defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_UNIX)
-/**
- * Replaces all instances of oldChar with newChar in str.
- *
- * TODO: This function appears here and in picture_utils.[cpp|h] ;
- * we should add the implementation to src/core/SkString.cpp, write tests for it,
- * and remove it from elsewhere.
- */
-static void replace_char(SkString* str, const char oldChar, const char newChar) {
- if (NULL == str) {
- return;
- }
- for (size_t i = 0; i < str->size(); ++i) {
- if (oldChar == str->operator[](i)) {
- str->operator[](i) = newChar;
- }
- }
-}
-
static void decodeFileAndWrite(const char srcPath[], const SkString* writePath) {
SkBitmap bitmap;
SkFILEStream stream(srcPath);
@@ -506,10 +488,10 @@ static void decodeFileAndWrite(const char srcPath[], const SkString* writePath)
// Create a string representing just the filename itself, for use in json expectations.
SkString basename = SkOSPath::Basename(srcPath);
// Replace '_' with '-', so that the names can fit gm_json.py's IMAGE_FILENAME_PATTERN
- replace_char(&basename, '_', '-');
+ basename.replace('_', '-');
// Replace '.' with '-', so the output filename can still retain the original file extension,
// but still end up with only one '.', which denotes the actual extension of the final file.
- replace_char(&basename, '.', '-');
+ basename.replace('.', '-');
const char* filename = basename.c_str();
if (!codec->decode(&stream, &bitmap, gPrefColorType, SkImageDecoder::kDecodePixels_Mode)) {

Powered by Google App Engine
This is Rietveld 408576698