Skip to content

Commit c7c738a

Browse files
stweilzdenop
authored andcommitted
lstm: Small code optimisation (#1426)
Replace float compare operation by integer compare operation and avoid float division if it is not needed. Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent 365611f commit c7c738a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lstm/input.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,9 @@ void Input::PreparePixInput(const StaticShape& shape, const Pix* pix,
138138
int height = pixGetHeight(normed_pix);
139139
int target_height = shape.height();
140140
if (target_height == 1) target_height = shape.depth();
141-
if (target_height == 0) target_height = height;
142-
float im_factor = static_cast<float>(target_height) / height;
143-
if (im_factor != 1.0f) {
141+
if (target_height != 0 && target_height != height) {
144142
// Get the scaled image.
143+
float im_factor = static_cast<float>(target_height) / height;
145144
Pix* scaled_pix = pixScale(normed_pix, im_factor, im_factor);
146145
pixDestroy(&normed_pix);
147146
normed_pix = scaled_pix;

0 commit comments

Comments
 (0)