[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCHv2] dprintf implementation
From: |
Aki Tossavainen |
Subject: |
Re: [PATCHv2] dprintf implementation |
Date: |
Fri, 25 Feb 2005 18:13:34 +0200 (EET) |
On Fri, 25 Feb 2005, Hollis Blanchard wrote:
> On Feb 25, 2005, at 5:52 AM, Vincent Pelletier wrote:
> >
> > grub_strword (string, word) : searches for word (a serie of
> > non-word-separators eventualy ended by word-separators) in string (a
> > succession of 0 or more words which can begin by word-separator(s))
>
> grub_strword looks a little overcomplicated; would something like this
> work?
>
Um, well, it does a lot of unnecessary expensive strcmp's there...
But if you add this, you can at least reduce them abit, since you are only
interested on the words.
> int
> grub_strword (const char *haystack, const char *needle)
> {
> int pos = 0;
> int found = 0;
>
> while (haystack[pos]) {
> /* Advance to next word. */
> while (grub_iswordseparator (haystack[pos]))
> pos++;
>
> if (0 == grub_strcmp (&haystack[pos], needle))
> {
> found = 1;
> break;
> }
else {
while (!grub_iswordseparator (haystack[pos]))
pos++;
}
> }
>
> return found;
> }
>
> That assumes 'needle' contains no separator characters. I think that's
> a safe assumption, given that 'needle' should come from a list of
> #defines. Or we could even sanity-check that in grub_strword, which
> IMHO would still be simpler than your earlier code.
>
> Also, don't forget to add double spaces after periods in comments;
> otherwise the emacs^W"style" police will kick in your door and make you
> write 500 ChangeLog entries as punishment.
>
> -Hollis
>
>
>
> _______________________________________________
> Grub-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/grub-devel
>
- [PATCH] dprintf implementation, Vincent Pelletier, 2005/02/21
- Re: [PATCH] dprintf implementation, Hollis Blanchard, 2005/02/23
- Re: [PATCH] dprintf implementation, Vincent Pelletier, 2005/02/24
- Re: [PATCH] dprintf implementation, Aki Tossavainen, 2005/02/24
- Re: [PATCH] dprintf implementation, Yoshinori K. Okuji, 2005/02/24
- Re: [PATCH] dprintf implementation, Vincent Pelletier, 2005/02/24
- Re: [PATCH] dprintf implementation, Hollis Blanchard, 2005/02/24
- Re: [PATCH] dprintf implementation, Aki Tossavainen, 2005/02/25
- [PATCHv2] dprintf implementation, Vincent Pelletier, 2005/02/25
- Re: [PATCHv2] dprintf implementation, Hollis Blanchard, 2005/02/25
- Re: [PATCHv2] dprintf implementation,
Aki Tossavainen <=
- Re: [PATCHv2] dprintf implementation, Hollis Blanchard, 2005/02/25
- Re: [PATCHv2] dprintf implementation, Yoshinori K. Okuji, 2005/02/25
- Re: [PATCHv2] dprintf implementation, Vincent Pelletier, 2005/02/25
- Re: [PATCHv2] dprintf implementation, Yoshinori K. Okuji, 2005/02/25