Skip to content

Commit

Permalink
Migrate String8|16.setTo to assignment operator [mainline]
Browse files Browse the repository at this point in the history
Bug: 295394788
Test: make checkbuild
Change-Id: I4c04ea40447a48d0209cbdcaed1695dd7b8aa68b
  • Loading branch information
twasilczyk committed Aug 23, 2023
1 parent aebf8fe commit 9e975d9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion media/module/extractors/mp4/ItemTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions media/module/extractors/mp4/MPEG4Extractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}

Expand Down
48 changes: 24 additions & 24 deletions media/module/id3/ID3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand All @@ -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) {
Expand All @@ -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;
}

Expand Down Expand Up @@ -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...
Expand All @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 9e975d9

Please sign in to comment.