Skip to content

Commit 1789bb0

Browse files
committed
Use sqrtf() instead of sqrt() where is applies.
1 parent c01c454 commit 1789bb0

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

src/develop/masks/path.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ void _set_ctrl_angle(const float x_ref,
218218

219219
if(!move_p2) // move p1
220220
{
221-
const float length1 = sqrt((x1a - x_refa) * (x1a - x_refa) + (*y1 - y_ref) * (*y1 - y_ref));
221+
const float length1 = sqrtf((x1a - x_refa) * (x1a - x_refa) + (*y1 - y_ref) * (*y1 - y_ref));
222222
const float angle2 = angle_2d(x2a, *y2, x_refa, y_ref);
223223
const float angle1 = angle2 - angle;
224224

@@ -227,7 +227,7 @@ void _set_ctrl_angle(const float x_ref,
227227
}
228228
else // move p2
229229
{
230-
const float length2 = sqrt((x2a - x_refa) * (x2a - x_refa) + (*y2 - y_ref) * (*y2 - y_ref));
230+
const float length2 = sqrtf((x2a - x_refa) * (x2a - x_refa) + (*y2 - y_ref) * (*y2 - y_ref));
231231
const float angle1 = angle_2d(x1a, *y1, x_refa, y_ref);
232232
const float angle2 = angle1 + angle;
233233

@@ -262,8 +262,8 @@ float _get_ctrl_scale(const float x_ref,
262262
const float x2a = x2 * aspect_ratio;
263263
const float x_refa = x_ref * aspect_ratio;
264264

265-
const float length1 = sqrt((x1a - x_refa) * (x1a - x_refa) + (y1 - y_ref) * (y1 - y_ref));
266-
const float length2 = sqrt((x2a - x_refa) * (x2a - x_refa) + (y2 - y_ref) * (y2 - y_ref));
265+
const float length1 = sqrtf((x1a - x_refa) * (x1a - x_refa) + (y1 - y_ref) * (y1 - y_ref));
266+
const float length2 = sqrtf((x2a - x_refa) * (x2a - x_refa) + (y2 - y_ref) * (y2 - y_ref));
267267
return length1 / length2;
268268
}
269269

@@ -299,7 +299,7 @@ void _set_ctrl_scale(const float x_ref,
299299

300300
if(!move_p2) // move p1
301301
{
302-
const float length2 = sqrt((x2a - x_refa) * (x2a - x_refa) + (*y2 - y_ref) * (*y2 - y_ref));
302+
const float length2 = sqrtf((x2a - x_refa) * (x2a - x_refa) + (*y2 - y_ref) * (*y2 - y_ref));
303303
const float angle1 = angle_2d(x1a, *y1, x_refa, y_ref);
304304
const float length1 = length2 * scale;
305305

@@ -308,7 +308,7 @@ void _set_ctrl_scale(const float x_ref,
308308
}
309309
else // move p2
310310
{
311-
const float length1 = sqrt((x1a - x_refa) * (x1a - x_refa) + (*y1 - y_ref) * (*y1 - y_ref));
311+
const float length1 = sqrtf((x1a - x_refa) * (x1a - x_refa) + (*y1 - y_ref) * (*y1 - y_ref));
312312
const float angle2 = angle_2d(x2a, *y2, x_refa, y_ref);
313313
const float length2 = length1 / scale;
314314

@@ -3563,8 +3563,8 @@ static void _path_falloff_roi(float *buffer,
35633563
const int bh)
35643564
{
35653565
// segment length
3566-
const int l = sqrt((p1[0] - p0[0]) * (p1[0] - p0[0])
3567-
+ (p1[1] - p0[1]) * (p1[1] - p0[1])) + 1;
3566+
const int l = sqrtf((p1[0] - p0[0]) * (p1[0] - p0[0])
3567+
+ (p1[1] - p0[1]) * (p1[1] - p0[1])) + 1;
35683568

35693569
const float lx = p1[0] - p0[0];
35703570
const float ly = p1[1] - p0[1];

src/dtgtk/culling.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,8 +1403,8 @@ static gboolean _thumbs_compute_positions(dt_culling_t *table)
14031403
{
14041404
dt_thumbnail_t *thumb = l->data;
14051405
const float aspect_ratio = thumb->aspect_ratio;
1406-
thumb->width = (gint)(sqrt(aspect_ratio) * 100);
1407-
thumb->height = (gint)(1 / sqrt(aspect_ratio) * 100);
1406+
thumb->width = (gint)(sqrtf(aspect_ratio) * 100);
1407+
thumb->height = (gint)(1 / sqrtf(aspect_ratio) * 100);
14081408
thumb->x = thumb->y = 0;
14091409

14101410
max_thumb_height = MAX(max_thumb_height, thumb->height);

src/iop/soften.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ void process(dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, const void *c
132132

133133
const float w = piece->iwidth * piece->iscale;
134134
const float h = piece->iheight * piece->iscale;
135-
const int mrad = sqrt(w * w + h * h) * 0.01;
136-
const int rad = mrad * (fmin(100.0, d->size + 1) / 100.0);
135+
const int mrad = dt_fast_hypotf(w, h) * 0.01f;
136+
const int rad = mrad * (fmin(100.0, d->size + 1.0f) / 100.0);
137137
const int radius = MIN(mrad, ceilf(rad * roi_in->scale / piece->iscale));
138138

139139
dt_box_mean(out, roi_out->height, roi_out->width, 4, radius, BOX_ITERATIONS);
@@ -167,9 +167,9 @@ int process_cl(dt_iop_module_t *self,
167167

168168
const float w = piece->iwidth * piece->iscale;
169169
const float h = piece->iheight * piece->iscale;
170-
const int mrad = sqrt(w * w + h * h) * 0.01f;
170+
const int mrad = dt_fast_hypotf(w, h) * 0.01f;
171171

172-
const int rad = mrad * (fmin(100.0f, d->size + 1) / 100.0f);
172+
const int rad = mrad * (fmin(100.0f, d->size + 1.0f) / 100.0f);
173173
const int radius = MIN(mrad, ceilf(rad * roi_in->scale / piece->iscale));
174174

175175
/* sigma-radius correlation to match opencl vs. non-opencl. identified by numerical experiments but
@@ -280,9 +280,9 @@ void tiling_callback(dt_iop_module_t *self,
280280

281281
const float w = piece->iwidth * piece->iscale;
282282
const float h = piece->iheight * piece->iscale;
283-
const int mrad = sqrt(w * w + h * h) * 0.01f;
283+
const int mrad = dt_fast_hypotf(w, h) * 0.01f;
284284

285-
const int rad = mrad * (fmin(100.0f, d->size + 1) / 100.0f);
285+
const int rad = mrad * (fmin(100.0f, d->size + 1.0f) / 100.0f);
286286
const int radius = MIN(mrad, ceilf(rad * roi_in->scale / piece->iscale));
287287

288288
/* sigma-radius correlation to match opencl vs. non-opencl. identified by numerical experiments but
@@ -371,4 +371,3 @@ void gui_init(dt_iop_module_t *self)
371371
// vim: shiftwidth=2 expandtab tabstop=2 cindent
372372
// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
373373
// clang-format on
374-

0 commit comments

Comments
 (0)