Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b57e014

Browse files
committed
Merge pull request #4527 from mdboom/stdlib-isfinit
Use C++ stdlib for isfinite etc.
2 parents e508f4e + 91b5113 commit b57e014

File tree

5 files changed

+13
-81
lines changed

5 files changed

+13
-81
lines changed

src/MPL_isnan.h

Lines changed: 0 additions & 69 deletions
This file was deleted.

src/_backend_agg.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include "_backend_agg.h"
66
#include "mplutils.h"
7-
#include "MPL_isnan.h"
87

98
void BufferRegion::to_string_argb(uint8_t *buf)
109
{

src/_backend_agg.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#ifndef __BACKEND_AGG_H__
77
#define __BACKEND_AGG_H__
88

9+
#include <cmath>
910
#include <vector>
1011

1112
#include "agg_alpha_mask_u8.h"
@@ -597,7 +598,7 @@ inline void RendererAgg::draw_markers(GCAgg &gc,
597598

598599
if (has_clippath) {
599600
while (path_curve.vertex(&x, &y) != agg::path_cmd_stop) {
600-
if (MPL_notisfinite64(x) || MPL_notisfinite64(y)) {
601+
if (!(std::isfinite(x) && std::isfinite(y))) {
601602
continue;
602603
}
603604

@@ -629,7 +630,7 @@ inline void RendererAgg::draw_markers(GCAgg &gc,
629630
}
630631
} else {
631632
while (path_curve.vertex(&x, &y) != agg::path_cmd_stop) {
632-
if (MPL_notisfinite64(x) || MPL_notisfinite64(y)) {
633+
if (!(std::isfinite(x) && std::isfinite(y))) {
633634
continue;
634635
}
635636

src/_path.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <limits>
77
#include <math.h>
88
#include <vector>
9+
#include <cmath>
910

1011
#include "agg_conv_contour.h"
1112
#include "agg_conv_curve.h"
@@ -102,7 +103,7 @@ void point_in_path_impl(PointArray &points, PathIterator &path, ResultArray &ins
102103
for (i = 0; i < n; ++i) {
103104
ty = points[i][1];
104105

105-
if (MPL_isfinite64(ty)) {
106+
if (std::isfinite(ty)) {
106107
// get test bit for above/below X axis
107108
yflag0[i] = (vty0 >= ty);
108109

@@ -126,7 +127,7 @@ void point_in_path_impl(PointArray &points, PathIterator &path, ResultArray &ins
126127
tx = points[i][0];
127128
ty = points[i][1];
128129

129-
if (MPL_notisfinite64(tx) || MPL_notisfinite64(ty)) {
130+
if (!(std::isfinite(tx) && std::isfinite(ty))) {
130131
continue;
131132
}
132133

@@ -174,7 +175,7 @@ void point_in_path_impl(PointArray &points, PathIterator &path, ResultArray &ins
174175
tx = points[i][0];
175176
ty = points[i][1];
176177

177-
if (MPL_notisfinite64(tx) || MPL_notisfinite64(ty)) {
178+
if (!(std::isfinite(tx) && std::isfinite(ty))) {
178179
continue;
179180
}
180181

src/path_converters.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
#ifndef __PATH_CONVERTERS_H__
44
#define __PATH_CONVERTERS_H__
55

6+
#include <cmath>
67
#include "agg_path_storage.h"
78
#include "agg_clip_liang_barsky.h"
8-
#include "MPL_isnan.h"
99
#include "mplutils.h"
1010
#include "agg_conv_segmentator.h"
1111

@@ -176,14 +176,14 @@ class PathNanRemover : protected EmbeddedQueue<4>
176176
}
177177

178178
size_t num_extra_points = num_extra_points_map[code & 0xF];
179-
bool has_nan = (MPL_notisfinite64(*x) || MPL_notisfinite64(*y));
179+
bool has_nan = (!(std::isfinite(*x) && std::isfinite(*y)));
180180
queue_push(code, *x, *y);
181181

182182
/* Note: this test can not be short-circuited, since we need to
183183
advance through the entire curve no matter what */
184184
for (size_t i = 0; i < num_extra_points; ++i) {
185185
m_source->vertex(x, y);
186-
has_nan = has_nan || (MPL_notisfinite64(*x) || MPL_notisfinite64(*y));
186+
has_nan = has_nan || !(std::isfinite(*x) && std::isfinite(*y));
187187
queue_push(code, *x, *y);
188188
}
189189

@@ -196,7 +196,7 @@ class PathNanRemover : protected EmbeddedQueue<4>
196196
/* If the last point is finite, we use that for the
197197
moveto, otherwise, we'll use the first vertex of
198198
the next curve. */
199-
if (!(MPL_notisfinite64(*x) || MPL_notisfinite64(*y))) {
199+
if (std::isfinite(*x) && std::isfinite(*y)) {
200200
queue_push(agg::path_cmd_move_to, *x, *y);
201201
needs_move_to = false;
202202
} else {
@@ -219,14 +219,14 @@ class PathNanRemover : protected EmbeddedQueue<4>
219219
return code;
220220
}
221221

222-
if (MPL_notisfinite64(*x) || MPL_notisfinite64(*y)) {
222+
if (!(std::isfinite(*x) && std::isfinite(*y))) {
223223
do {
224224
code = m_source->vertex(x, y);
225225
if (code == agg::path_cmd_stop ||
226226
code == (agg::path_cmd_end_poly | agg::path_flags_close)) {
227227
return code;
228228
}
229-
} while (MPL_notisfinite64(*x) || MPL_notisfinite64(*y));
229+
} while (!(std::isfinite(*x) && std::isfinite(*y)));
230230
return agg::path_cmd_move_to;
231231
}
232232

0 commit comments

Comments
 (0)