summaryrefslogtreecommitdiffhomepage
path: root/ir/tv
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2014-12-30 04:48:14 +0100
committerMatthias Braun <matze@braunis.de>2014-12-30 11:09:08 +0100
commit2cc90595277b17bd9f0d8a0b0e869786e08f062d (patch)
tree3406e0291998ba97c9b6511f43d6dbf0a5c058a2 /ir/tv
parent5df35c11a43fa88b8a645cfe929ebb12d6f7956a (diff)
tv: remove space skipping feature and len == 0 handling from new_tarval_from_str_int()
The tarval module is not the place to validate your input, leave that to frontends and others... This way the code is simpler and slightly faster.
Diffstat (limited to 'ir/tv')
-rw-r--r--ir/tv/tv.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/ir/tv/tv.c b/ir/tv/tv.c
index 4b0b0eb..adb3e75 100644
--- a/ir/tv/tv.c
+++ b/ir/tv/tv.c
@@ -153,13 +153,7 @@ ir_tarval *new_integer_tarval_from_str(const char *str, size_t len,
static ir_tarval *new_tarval_from_str_int(const char *str, size_t len,
ir_mode *mode)
{
- /* skip leading spaces */
- while (len > 0 && str[0] == ' ') {
- ++str;
- --len;
- }
- if (len == 0)
- return tarval_bad;
+ assert(len > 0);
/* 1 sign character allowed */
bool negative = false;
@@ -190,8 +184,7 @@ static ir_tarval *new_tarval_from_str_int(const char *str, size_t len,
base = 8;
}
}
- if (len == 0)
- return tarval_bad;
+ assert(len > 0);
sc_word *buffer = ALLOCAN(sc_word, sc_value_length);
bool ok = sc_val_from_str(negative, base, str, len, buffer);