aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/catapult_dct2000.c
diff options
context:
space:
mode:
authorMartin Mathieson <martin.r.mathieson@googlemail.com>2018-01-27 23:35:03 +0000
committerAnders Broman <a.broman58@gmail.com>2018-01-29 10:45:19 +0000
commit8333c02731b23d364dd84b210d3cd0f0a164f7da (patch)
tree5ca3377aa9cd9bbca35951007dd63015cb35688e /wiretap/catapult_dct2000.c
parentc21b2e7f94feabd35672c3a56f3ec17fa6675c9e (diff)
dct2000: for speed, avoid ws_strtoi32() while reading timestamp
Change-Id: I5d8797b68c53168d4c00be8c3c3a3325b370e38c Reviewed-on: https://code.wireshark.org/review/25492 Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'wiretap/catapult_dct2000.c')
-rw-r--r--wiretap/catapult_dct2000.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/wiretap/catapult_dct2000.c b/wiretap/catapult_dct2000.c
index 76122c239f..c3e7dc63ac 100644
--- a/wiretap/catapult_dct2000.c
+++ b/wiretap/catapult_dct2000.c
@@ -1187,8 +1187,12 @@ parse_line(gchar *linebuff, gint line_length,
/* Convert found value into number */
seconds_buff[seconds_chars] = '\0';
- if (!ws_strtoi32(seconds_buff, NULL, seconds)) {
- return FALSE;
+ /* Already know they are digits, so avoid expense of ws_strtoi32() */
+ int multiplier = 1;
+ *seconds = 0;
+ for (int d=seconds_chars-1; d >= 0; d--) {
+ *seconds += ((seconds_buff[d]-'0')*multiplier);
+ multiplier *= 10;
}
/* The decimal point must follow the last of the seconds digits */
@@ -1216,10 +1220,11 @@ parse_line(gchar *linebuff, gint line_length,
}
/* Convert found value into microseconds */
subsecond_decimals_buff[subsecond_decimals_chars] = '\0';
- if (!ws_strtoi32(subsecond_decimals_buff, NULL, useconds)) {
- return FALSE;
- }
- (*useconds) *= 100;
+ /* Already know they are digits, so avoid expense of ws_strtoi32() */
+ *useconds = ((subsecond_decimals_buff[0]-'0') * 100000) +
+ ((subsecond_decimals_buff[1]-'0') * 10000) +
+ ((subsecond_decimals_buff[2]-'0') * 1000) +
+ ((subsecond_decimals_buff[3]-'0') * 100);
/* Space character must follow end of timestamp */
if (linebuff[n] != ' ') {