From 9e975d95c02225621f608c604bc10b1b63aa55da Mon Sep 17 00:00:00 2001 From: Tomasz Wasilczyk Date: Wed, 23 Aug 2023 22:11:17 +0000 Subject: [PATCH] Migrate String8|16.setTo to assignment operator [mainline] Bug: 295394788 Test: make checkbuild Change-Id: I4c04ea40447a48d0209cbdcaed1695dd7b8aa68b --- media/module/extractors/mp4/ItemTable.cpp | 2 +- .../module/extractors/mp4/MPEG4Extractor.cpp | 8 ++-- media/module/id3/ID3.cpp | 48 +++++++++---------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/media/module/extractors/mp4/ItemTable.cpp b/media/module/extractors/mp4/ItemTable.cpp index 444664c232..7fe5ba778c 100644 --- a/media/module/extractors/mp4/ItemTable.cpp +++ b/media/module/extractors/mp4/ItemTable.cpp @@ -1111,7 +1111,7 @@ bool InfeBox::parseNullTerminatedString( } buf.push_back(tmp); if (tmp == 0) { - out->setTo(buf.array()); + *out = buf.array(); *offset = newOffset; *size = stopOffset - newOffset; diff --git a/media/module/extractors/mp4/MPEG4Extractor.cpp b/media/module/extractors/mp4/MPEG4Extractor.cpp index 6a1c5f1178..ecd937d0f6 100644 --- a/media/module/extractors/mp4/MPEG4Extractor.cpp +++ b/media/module/extractors/mp4/MPEG4Extractor.cpp @@ -847,7 +847,7 @@ static bool convertTimeToDate(int64_t time_1904, String8 *s) { struct tm* tm = gmtime(&time_1970); if (tm != NULL && strftime(tmp, sizeof(tmp), "%Y%m%dT%H%M%S.000Z", tm) > 0) { - s->setTo(tmp); + *s = tmp; return true; } return false; @@ -4082,10 +4082,10 @@ status_t MPEG4Extractor::parseITunesMetaData(off64_t offset, size_t size) { buffer[size] = '\0'; switch (mPath[5]) { case FOURCC("mean"): - mLastCommentMean.setTo((const char *)buffer + 4); + mLastCommentMean = ((const char *)buffer + 4); break; case FOURCC("name"): - mLastCommentName.setTo((const char *)buffer + 4); + mLastCommentName = ((const char *)buffer + 4); break; case FOURCC("data"): if (size < 8) { @@ -4094,7 +4094,7 @@ status_t MPEG4Extractor::parseITunesMetaData(off64_t offset, size_t size) { ALOGE("b/24346430"); return ERROR_MALFORMED; } - mLastCommentData.setTo((const char *)buffer + 8); + mLastCommentData = ((const char *)buffer + 8); break; } diff --git a/media/module/id3/ID3.cpp b/media/module/id3/ID3.cpp index 1f3cad98a7..aaaeeaf72e 100644 --- a/media/module/id3/ID3.cpp +++ b/media/module/id3/ID3.cpp @@ -535,40 +535,40 @@ void ID3::Iterator::next() { } void ID3::Iterator::getID(String8 *id) const { - id->setTo(""); + *id = ""; if (mFrameData == NULL) { return; } if (mParent.mVersion == ID3_V2_2) { - id->setTo((const char *)&mParent.mData[mOffset], 3); + *id = String8((const char *)&mParent.mData[mOffset], 3); } else if (mParent.mVersion == ID3_V2_3 || mParent.mVersion == ID3_V2_4) { - id->setTo((const char *)&mParent.mData[mOffset], 4); + *id = String8((const char *)&mParent.mData[mOffset], 4); } else { CHECK(mParent.mVersion == ID3_V1 || mParent.mVersion == ID3_V1_1); switch (mOffset) { case 3: - id->setTo("TT2"); + *id = "TT2"; break; case 33: - id->setTo("TP1"); + *id = "TP1"; break; case 63: - id->setTo("TAL"); + *id = "TAL"; break; case 93: - id->setTo("TYE"); + *id = "TYE"; break; case 97: - id->setTo("COM"); + *id = "COM"; break; case 126: - id->setTo("TRK"); + *id = "TRK"; break; case 127: - id->setTo("TCO"); + *id = "TCO"; break; default: CHECK(!"should not be here."); @@ -590,7 +590,7 @@ void ID3::Iterator::getString(String8 *id, String8 *comment) const { // followed by more data. The data following the \0 can be retrieved by setting // "otherdata" to true. void ID3::Iterator::getstring(String8 *id, bool otherdata) const { - id->setTo(""); + *id = ""; const uint8_t *frameData = mFrameData; if (frameData == NULL) { @@ -605,13 +605,13 @@ void ID3::Iterator::getstring(String8 *id, bool otherdata) const { char tmp[16]; snprintf(tmp, sizeof(tmp), "%d", (int)*frameData); - id->setTo(tmp); + *id = tmp; return; } // this is supposed to be ISO-8859-1, but pass it up as-is to the caller, who will figure // out the real encoding - id->setTo((const char*)frameData, mFrameSize); + *id = String8((const char*)frameData, mFrameSize); return; } @@ -640,10 +640,10 @@ void ID3::Iterator::getstring(String8 *id, bool otherdata) const { if (encoding == 0x00) { // supposedly ISO 8859-1 - id->setTo((const char*)frameData + 1, n); + *id = String8((const char*)frameData + 1, n); } else if (encoding == 0x03) { // supposedly UTF-8 - id->setTo((const char *)(frameData + 1), n); + *id = String8((const char *)(frameData + 1), n); } else if (encoding == 0x02) { // supposedly UTF-16 BE, no byte order mark. // API wants number of characters, not number of bytes... @@ -662,7 +662,7 @@ void ID3::Iterator::getstring(String8 *id, bool otherdata) const { framedata = framedatacopy; } #endif - id->setTo(framedata, len); + *id = String8(framedata, len); if (framedatacopy != NULL) { delete[] framedatacopy; } @@ -715,13 +715,13 @@ void ID3::Iterator::getstring(String8 *id, bool otherdata) const { for (int i = 0; i < len; i++) { frame8[i] = framedata[i]; } - id->setTo(frame8, len); + *id = String8(frame8, len); delete [] frame8; } else { - id->setTo(framedata, len); + *id = String8(framedata, len); } } else { - id->setTo(framedata, len); + *id = String8(framedata, len); } if (framedatacopy != NULL) { @@ -948,7 +948,7 @@ static size_t StringSize(const uint8_t *start, size_t limit, uint8_t encoding) { const void * ID3::getAlbumArt(size_t *length, String8 *mime) const { *length = 0; - mime->setTo(""); + *mime = ""; Iterator it( *this, @@ -971,7 +971,7 @@ ID3::getAlbumArt(size_t *length, String8 *mime) const { ALOGW("bogus album art size: mime"); return NULL; } - mime->setTo((const char *)&data[consumed]); + *mime = (const char *)&data[consumed]; consumed += mimeLen; #if 0 @@ -1008,11 +1008,11 @@ ID3::getAlbumArt(size_t *length, String8 *mime) const { } if (!memcmp(&data[1], "PNG", 3)) { - mime->setTo("image/png"); + *mime = "image/png"; } else if (!memcmp(&data[1], "JPG", 3)) { - mime->setTo("image/jpeg"); + *mime = "image/jpeg"; } else if (!memcmp(&data[1], "-->", 3)) { - mime->setTo("text/plain"); + *mime = "text/plain"; } else { return NULL; }