libragephoto: use zeroBuffer to improve efficiency
This commit is contained in:
parent
534d978e47
commit
6046b7213a
2 changed files with 18 additions and 54 deletions
|
@ -760,9 +760,7 @@ bool ragephotodata_savef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parse
|
||||||
writeBuffer(uInt32Buffer, data, &pos, length, 4);
|
writeBuffer(uInt32Buffer, data, &pos, length, 4);
|
||||||
|
|
||||||
writeBuffer(photoHeader, data, &pos, length, photoHeader_size);
|
writeBuffer(photoHeader, data, &pos, length, photoHeader_size);
|
||||||
for (size_t i = photoHeader_size; i < 256; i++) {
|
zeroBuffer(data, &pos, length, 256 - photoHeader_size);
|
||||||
writeBuffer("\0", data, &pos, length, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||||
memcpy(uInt32Buffer, &rp_data->headerSum, 4);
|
memcpy(uInt32Buffer, &rp_data->headerSum, 4);
|
||||||
|
@ -835,14 +833,10 @@ bool ragephotodata_savef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parse
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
writeBuffer(rp_data->jpeg, data, &pos, length, rp_data->jpegSize);
|
writeBuffer(rp_data->jpeg, data, &pos, length, rp_data->jpegSize);
|
||||||
for (size_t i = rp_data->jpegSize; i < rp_data->jpegBuffer; i++) {
|
zeroBuffer(data, &pos, length, rp_data->jpegBuffer - rp_data->jpegSize);
|
||||||
writeBuffer("\0", data, &pos, length, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (size_t i = 0; i < rp_data->jpegBuffer; i++) {
|
zeroBuffer(data, &pos, length, rp_data->jpegBuffer - rp_data->jpegSize);
|
||||||
writeBuffer("\0", data, &pos, length, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = rp_data->jsonOffset + headerSize;
|
pos = rp_data->jsonOffset + headerSize;
|
||||||
|
@ -862,14 +856,10 @@ bool ragephotodata_savef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parse
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
writeBuffer(rp_data->json, data, &pos, length, jsonString_size);
|
writeBuffer(rp_data->json, data, &pos, length, jsonString_size);
|
||||||
for (size_t i = jsonString_size; i < rp_data->jsonBuffer; i++) {
|
zeroBuffer(data, &pos, length, rp_data->jsonBuffer - jsonString_size);
|
||||||
writeBuffer("\0", data, &pos, length, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (size_t i = 0; i < rp_data->jsonBuffer; i++) {
|
zeroBuffer(data, &pos, length, rp_data->jsonBuffer);
|
||||||
writeBuffer("\0", data, &pos, length, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = rp_data->titlOffset + headerSize;
|
pos = rp_data->titlOffset + headerSize;
|
||||||
|
@ -889,14 +879,10 @@ bool ragephotodata_savef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parse
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
writeBuffer(rp_data->title, data, &pos, length, titlString_size);
|
writeBuffer(rp_data->title, data, &pos, length, titlString_size);
|
||||||
for (size_t i = titlString_size; i < rp_data->titlBuffer; i++) {
|
zeroBuffer(data, &pos, length, rp_data->titlBuffer - titlString_size);
|
||||||
writeBuffer("\0", data, &pos, length, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (size_t i = 0; i < rp_data->titlBuffer; i++) {
|
zeroBuffer(data, &pos, length, rp_data->titlBuffer);
|
||||||
writeBuffer("\0", data, &pos, length, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = rp_data->descOffset + headerSize;
|
pos = rp_data->descOffset + headerSize;
|
||||||
|
@ -916,14 +902,10 @@ bool ragephotodata_savef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parse
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
writeBuffer(rp_data->description, data, &pos, length, descString_size);
|
writeBuffer(rp_data->description, data, &pos, length, descString_size);
|
||||||
for (size_t i = descString_size; i < rp_data->descBuffer; i++) {
|
zeroBuffer(data, &pos, length, rp_data->descBuffer - descString_size);
|
||||||
writeBuffer("\0", data, &pos, length, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (size_t i = 0; i < rp_data->descBuffer; i++) {
|
zeroBuffer(data, &pos, length, rp_data->descBuffer);
|
||||||
writeBuffer("\0", data, &pos, length, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = rp_data->endOfFile + headerSize - 4;
|
pos = rp_data->endOfFile + headerSize - 4;
|
||||||
|
|
|
@ -780,9 +780,7 @@ bool RagePhoto::save(char *data, uint32_t photoFormat, RagePhotoData *rp_data, R
|
||||||
writeBuffer(uInt32Buffer, data, &pos, length, 4);
|
writeBuffer(uInt32Buffer, data, &pos, length, 4);
|
||||||
|
|
||||||
writeBuffer(photoHeader, data, &pos, length, photoHeader_size);
|
writeBuffer(photoHeader, data, &pos, length, photoHeader_size);
|
||||||
for (size_t i = photoHeader_size; i < 256; i++) {
|
zeroBuffer(data, &pos, length, 256 - photoHeader_size);
|
||||||
writeBuffer("\0", data, &pos, length, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||||
memcpy(uInt32Buffer, &rp_data->headerSum, 4);
|
memcpy(uInt32Buffer, &rp_data->headerSum, 4);
|
||||||
|
@ -854,14 +852,10 @@ bool RagePhoto::save(char *data, uint32_t photoFormat, RagePhotoData *rp_data, R
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
writeBuffer(rp_data->jpeg, data, &pos, length, rp_data->jpegSize);
|
writeBuffer(rp_data->jpeg, data, &pos, length, rp_data->jpegSize);
|
||||||
for (size_t i = rp_data->jpegSize; i < rp_data->jpegBuffer; i++) {
|
zeroBuffer(data, &pos, length, rp_data->jpegBuffer - rp_data->jpegSize);
|
||||||
writeBuffer("\0", data, &pos, length, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (size_t i = 0; i < rp_data->jpegBuffer; i++) {
|
zeroBuffer(data, &pos, length, rp_data->jpegBuffer - rp_data->jpegSize);
|
||||||
writeBuffer("\0", data, &pos, length, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = rp_data->jsonOffset + headerSize;
|
pos = rp_data->jsonOffset + headerSize;
|
||||||
|
@ -881,14 +875,10 @@ bool RagePhoto::save(char *data, uint32_t photoFormat, RagePhotoData *rp_data, R
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
writeBuffer(rp_data->json, data, &pos, length, jsonString_size);
|
writeBuffer(rp_data->json, data, &pos, length, jsonString_size);
|
||||||
for (size_t i = jsonString_size; i < rp_data->jsonBuffer; i++) {
|
zeroBuffer(data, &pos, length, rp_data->jsonBuffer - jsonString_size);
|
||||||
writeBuffer("\0", data, &pos, length, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (size_t i = 0; i < rp_data->jsonBuffer; i++) {
|
zeroBuffer(data, &pos, length, rp_data->jsonBuffer);
|
||||||
writeBuffer("\0", data, &pos, length, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = rp_data->titlOffset + headerSize;
|
pos = rp_data->titlOffset + headerSize;
|
||||||
|
@ -908,14 +898,10 @@ bool RagePhoto::save(char *data, uint32_t photoFormat, RagePhotoData *rp_data, R
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
writeBuffer(rp_data->title, data, &pos, length, titlString_size);
|
writeBuffer(rp_data->title, data, &pos, length, titlString_size);
|
||||||
for (size_t i = titlString_size; i < rp_data->titlBuffer; i++) {
|
zeroBuffer(data, &pos, length, rp_data->titlBuffer - titlString_size);
|
||||||
writeBuffer("\0", data, &pos, length, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (size_t i = 0; i < rp_data->titlBuffer; i++) {
|
zeroBuffer(data, &pos, length, rp_data->titlBuffer);
|
||||||
writeBuffer("\0", data, &pos, length, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = rp_data->descOffset + headerSize;
|
pos = rp_data->descOffset + headerSize;
|
||||||
|
@ -935,14 +921,10 @@ bool RagePhoto::save(char *data, uint32_t photoFormat, RagePhotoData *rp_data, R
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
writeBuffer(rp_data->description, data, &pos, length, descString_size);
|
writeBuffer(rp_data->description, data, &pos, length, descString_size);
|
||||||
for (size_t i = descString_size; i < rp_data->descBuffer; i++) {
|
zeroBuffer(data, &pos, length, rp_data->descBuffer - descString_size);
|
||||||
writeBuffer("\0", data, &pos, length, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (size_t i = 0; i < rp_data->descBuffer; i++) {
|
zeroBuffer(data, &pos, length, rp_data->descBuffer);
|
||||||
writeBuffer("\0", data, &pos, length, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = rp_data->endOfFile + headerSize - 4;
|
pos = rp_data->endOfFile + headerSize - 4;
|
||||||
|
|
Loading…
Reference in a new issue