Re: this is simpler code
- From: Tim Janik <timj gtk org>
- To: gtk-devel-list redhat com
- Subject: Re: this is simpler code
- Date: Sun, 15 Aug 1999 07:16:50 +0200 (CEST)
On Sat, 14 Aug 1999, Russell Nelson wrote:
> Taken from gtkitemfactory.c. Shouldn't the following snippet of code:
>
> if (scanner->token == G_TOKEN_SYMBOL)
> {
> guint (*parser_func) (GScanner*, GtkItemFactoryClass*);
>
> parser_func = scanner->value.v_symbol;
>
> /* check whether this is a GtkItemFactory symbol.
> */
> if (parser_func == gtk_item_factory_parse_menu_path)
> expected_token = parser_func (scanner, class);
> else
> expected_token = G_TOKEN_SYMBOL;
> }
>
> look like this instead:
>
> if (scanner->token == G_TOKEN_SYMBOL)
> {
> /* check whether this is a GtkItemFactory symbol.
> */
> if (scanner->value.v_symbol == gtk_item_factory_parse_menu_path)
> expected_token = gtk_item_factory_parse_menu_path (scanner, class);
> else
> expected_token = G_TOKEN_SYMBOL;
> }
>
> ? Why bother with parser_func, when removing it makes the code
> simpler and easier to understand?
because i initially mean to support different kinds of symbols, then
parser_func = scanner->value.v_symbol could have pointed to a variety
of functions. but as it turned out, i only needed to feature one
symbol, and didn't bother to simplify that code portion when i was sure
that matters won't change anymore.
>
> --
> -russ nelson <nelson@crynwr.com> http://russnelson.com
> Crynwr sells support for free software | PGPok | Government schools are so
> 521 Pleasant Valley Rd. | +1 315 268 1925 voice | bad that any rank amateur
> Potsdam, NY 13676-3213 | +1 315 268 9201 FAX | can outdo them. Homeschool!
>
>
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]