Skip to content

Commit 9a2a2be

Browse files
committed
fix: address C++ comments
1 parent cfe8795 commit 9a2a2be

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

common/rnexecutorch/data_processing/ImageProcessing.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ cv::Mat bufferToColorMat(const std::span<const float> &buffer,
4949
for (int i = 0; i < pixelCount; i++) {
5050
int row = i / matSize.width;
5151
int col = i % matSize.width;
52-
float r = 0, g = 0, b = 0;
5352

54-
r = buffer[0 * pixelCount + i];
55-
g = buffer[1 * pixelCount + i];
56-
b = buffer[2 * pixelCount + i];
53+
float r = buffer[0 * pixelCount + i];
54+
float g = buffer[1 * pixelCount + i];
55+
float b = buffer[2 * pixelCount + i];
5756

58-
cv::Vec3b color((uchar)(b * 255), (uchar)(g * 255), (uchar)(r * 255));
57+
cv::Vec3b color(static_cast<uchar>(b * 255), static_cast<uchar>(g * 255),
58+
static_cast<uchar>(r * 255));
5959
mat.at<cv::Vec3b>(row, col) = color;
6060
}
6161

common/rnexecutorch/host_objects/ModelHostObject.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <cstdio>
12
#include <string>
23
#include <tuple>
34
#include <vector>
@@ -27,7 +28,13 @@ template <typename Model> class ModelHostObject : public JsiHostObject {
2728
constexpr std::size_t forwardArgCount =
2829
jsiconversion::getArgumentCount(&Model::forward);
2930
if (forwardArgCount != count) {
30-
promise->reject("Argument count mismatch");
31+
char errorMessage[100];
32+
std::snprintf(
33+
errorMessage, sizeof(errorMessage),
34+
"Argument count mismatch, was expecting: %zu but got: %zu",
35+
forwardArgCount, count);
36+
37+
promise->reject(errorMessage);
3138
return;
3239
}
3340

common/rnexecutorch/models/BaseModel.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ std::vector<int32_t> BaseModel::getInputShape() {
3232
}
3333

3434
auto shape = input_meta->sizes();
35-
std::vector<int32_t> output(shape.size());
36-
for (int i = 0; i < shape.size(); i++) {
37-
output[i] = shape[i];
38-
}
35+
std::vector<int32_t> output(shape.begin(), shape.end());
3936

4037
return output;
4138
}

0 commit comments

Comments
 (0)