On Fri, 2011-12-09 at 12:34 -0700, Eric Blake wrote:
On 12/08/2011 05:38 PM, Eric Blake wrote:
>> int i;
>> for (i = 0 ; i < strlen(model) ; i++) {
Hmm - an O(n) function call on an O(n) loop, for a quadratic action (of
course, it's in the noise, since the user's model name is likely short).
But we can do better with a more efficient search for bogus bytes
(strspn is O(n), if implemented well in libc).
>> - int char_ok = c_isalnum(model[i]) || model[i] == '_';
>> - if (!char_ok) {
>> + if (!c_isalnum(model[i]) && model[i] != '_'
&& model[i] != '-') {
>
> I'm not sure if we need to tweak our RNG grammar to also allow this in
> the XML validation. I'll check that out tomorrow, when I get around to
> applying this one and reviewing the rest of the series.
It turns out the XML didn't do any validation at all. Here's what I
came up with - tightening the RNG and relaxing the domain_conf code, so
that they now match. Since the concept is the same as yours, I went
ahead and pushed it, but I claimed authorship on this one, since I
practically rewrote it.
Yep fair enough. Your new version is much nicer, looks good.
cheers