diff options
author | rcombs <rcombs@rcombs.me> | 2020-08-30 13:12:23 -0500 |
---|---|---|
committer | rcombs <rcombs@rcombs.me> | 2020-08-30 22:45:37 -0500 |
commit | e52ae4d1d326804574c90de1072873e848261508 (patch) | |
tree | 1d0412087963d49db049071728193f9dd2e759e1 /libass | |
parent | b3f9022b04ddf8872b99c28dd358d89e94dea12d (diff) | |
download | libass-e52ae4d1d326804574c90de1072873e848261508.tar.bz2 libass-e52ae4d1d326804574c90de1072873e848261508.tar.xz |
ass_utils: make ass_strtod/strtoll wrappers inlineable
Also makes a measurable difference on float-parse-heavy scripts,
and it's not like these had a reason to not be in the header.
Diffstat (limited to 'libass')
-rw-r--r-- | libass/ass_utils.c | 31 | ||||
-rw-r--r-- | libass/ass_utils.h | 35 |
2 files changed, 31 insertions, 35 deletions
diff --git a/libass/ass_utils.c b/libass/ass_utils.c index 99e2c52..893e2c5 100644 --- a/libass/ass_utils.c +++ b/libass/ass_utils.c @@ -154,37 +154,6 @@ void rskip_spaces(char **str, char *limit) *str = p; } -int mystrtoi(char **p, int *res) -{ - char *start = *p; - double temp_res = ass_strtod(*p, p); - *res = (int) (temp_res + (temp_res > 0 ? 0.5 : -0.5)); - return *p != start; -} - -int mystrtoll(char **p, long long *res) -{ - char *start = *p; - double temp_res = ass_strtod(*p, p); - *res = (long long) (temp_res + (temp_res > 0 ? 0.5 : -0.5)); - return *p != start; -} - -int mystrtod(char **p, double *res) -{ - char *start = *p; - *res = ass_strtod(*p, p); - return *p != start; -} - -int mystrtoi32(char **p, int base, int32_t *res) -{ - char *start = *p; - long long temp_res = strtoll(*p, p, base); - *res = FFMINMAX(temp_res, INT32_MIN, INT32_MAX); - return *p != start; -} - static int read_digits(char **str, int base, uint32_t *res) { char *p = *str; diff --git a/libass/ass_utils.h b/libass/ass_utils.h index 80d7529..ed17327 100644 --- a/libass/ass_utils.h +++ b/libass/ass_utils.h @@ -78,10 +78,6 @@ void *ass_try_realloc_array(void *ptr, size_t nmemb, size_t size); void skip_spaces(char **str); void rskip_spaces(char **str, char *limit); -int mystrtoi(char **p, int *res); -int mystrtoll(char **p, long long *res); -int mystrtod(char **p, double *res); -int mystrtoi32(char **p, int base, int32_t *res); int32_t parse_alpha_tag(char *str); uint32_t parse_color_tag(char *str); uint32_t parse_color_header(char *str); @@ -198,4 +194,35 @@ static inline uint32_t fnv_32a_str(const char *str, uint32_t hval) return hval; } +static inline int mystrtoi(char **p, int *res) +{ + char *start = *p; + double temp_res = ass_strtod(*p, p); + *res = (int) (temp_res + (temp_res > 0 ? 0.5 : -0.5)); + return *p != start; +} + +static inline int mystrtoll(char **p, long long *res) +{ + char *start = *p; + double temp_res = ass_strtod(*p, p); + *res = (long long) (temp_res + (temp_res > 0 ? 0.5 : -0.5)); + return *p != start; +} + +static inline int mystrtod(char **p, double *res) +{ + char *start = *p; + *res = ass_strtod(*p, p); + return *p != start; +} + +static inline int mystrtoi32(char **p, int base, int32_t *res) +{ + char *start = *p; + long long temp_res = strtoll(*p, p, base); + *res = FFMINMAX(temp_res, INT32_MIN, INT32_MAX); + return *p != start; +} + #endif /* LIBASS_UTILS_H */ |