RE: [PATCH] Add a basic date format check to DIDL-Lite parser (v3)
- From: Jens Georg <mail jensge org>
- To: Santakivi Topi <Topi Santakivi digia com>
- Cc: "gupnp-list gnome org" <gupnp-list gnome org>
- Subject: RE: [PATCH] Add a basic date format check to DIDL-Lite parser (v3)
- Date: Wed, 06 Jul 2011 18:07:59 +0200
On Mi, 2011-07-06 at 16:57 +0300, Santakivi Topi wrote:
> ---
> libgupnp-av/gupnp-didl-lite-parser.c | 61 +++++++++++++++++++++++++--------
> libgupnp-av/gupnp-didl-lite-parser.h | 4 ++-
> 2 files changed, 49 insertions(+), 16 deletions(-)
Actually the DFA approach we discussed on IRC would be less intrusive:
int state = 0;
char *ptr = date;
while (*ptr)
{
if (state == 4 || state == 7) {
if (*ptr != '-') {
break;
}
} else {
if (!isdigit(*ptr)) {
break;
}
state++;
ptr++;
if (state == 10)
return TRUE;
}
return FALSE;
And, just for reference:
For 10000 iterations checking a date like "1978-13-07", I get (on my
PC):
** (process:29594): DEBUG: DFA Matching took: 0.000909
** (process:29594): DEBUG: GRegexx Matching took: 0.008746
On arm:
dfa-date-check[9459]: GLIB DEBUG default - Matching took: 0.001648
dfa-date-check[9459]: GLIB DEBUG default - Matching took: 0.097443
So DFA time doubles while GRegex is times 10. :(
Still, as said before, this the sum of all 10000 executions, so for one
check it doesn't really matter, but the overall result is interesting
nevertheless.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]