Hi Bram,

On Fri, Jul 15, 2016 at 1:36 PM, Bram Moolenaar <[email protected]> wrote:
>
> Patch 7.4.2046
> Problem:    The qf_init_ext() function is too big.
> Solution:   Refactor it. (Yegappan Lakshmanan)
> Files:      src/quickfix.c
>

Thanks for merging this change and moving all the state into
qf_state_T. It looks much cleaner now. I also didn't like the
large number of arguments passed to these functions
previously.

Regards,
Yegappan

>
> *** ../vim-7.4.2045/src/quickfix.c      2016-07-10 22:11:11.870751341 +0200
> --- src/quickfix.c      2016-07-15 22:28:26.189971916 +0200
> ***************
> *** 187,217 ****
>    */
>   #define LINE_MAXLEN 4096
>
> -     static char_u *
> - qf_grow_linebuf(char_u **growbuf, int *growbufsiz, int newsz, int *allocsz)
> - {
> -     /*
> -      * If the line exceeds LINE_MAXLEN exclude the last
> -      * byte since it's not a NL character.
> -      */
> -     *allocsz = newsz > LINE_MAXLEN ? LINE_MAXLEN - 1 : newsz;
> -     if (*growbuf == NULL)
> -     {
> -       *growbuf = alloc(*allocsz + 1);
> -       if (*growbuf == NULL)
> -           return NULL;
> -       *growbufsiz = *allocsz;
> -     }
> -     else if (*allocsz > *growbufsiz)
> -     {
> -       *growbuf = vim_realloc(*growbuf, *allocsz + 1);
> -       if (*growbuf == NULL)
> -           return NULL;
> -       *growbufsiz = *allocsz;
> -     }
> -     return *growbuf;
> - }
> -
>   static struct fmtpattern
>   {
>       char_u    convchar;
> --- 187,192 ----
> ***************
> *** 496,501 ****
> --- 471,770 ----
>       return fmt_first;
>   }
>
> + enum {
> +     QF_FAIL = 0,
> +     QF_OK = 1,
> +     QF_END_OF_INPUT = 2,
> +     QF_NOMEM = 3
> + };
> +
> + typedef struct {
> +     char_u    *linebuf;
> +     int               linelen;
> +     char_u    *growbuf;
> +     int               growbufsiz;
> +     FILE      *fd;
> +     typval_T  *tv;
> +     char_u    *p_str;
> +     listitem_T        *p_li;
> +     buf_T     *buf;
> +     linenr_T  buflnum;
> +     linenr_T  lnumlast;
> + } qfstate_T;
> +

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
  • Patch 7.4.2046 Bram Moolenaar
    • Re: Patch 7.4.2046 Yegappan Lakshmanan

Raspunde prin e-mail lui