Patches item #1656984, was opened at 2007-02-10 17:25
Message generated for change (Comment added) made by nosnilmot
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=300235&aid=1656984&group_id=235

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Plugins
Group: None
>Status: Pending
Resolution: None
Priority: 5
Private: No
Submitted By: tombcore (tombcore)
Assigned to: Nobody/Anonymous (nobody)
Summary: little speed improvement in msn plugin

Initial Comment:
directconn write routine :
static size_t
msn_directconn_write(MsnDirectConn *directconn, const char *data, size_t len)
{
        char *Buffer;
        size_t buf_size;
        size_t ret;

        g_return_val_if_fail(directconn != NULL, 0);

        buf_size = len + 4;
        Buffer = g_malloc(buf_size);
        if (Buffer == NULL)
                return 0;

        /* Convert len int and paste it at the begining of buffer */
        *((guint32*)Buffer) = GUINT32_TO_LE(len);
        /* Then paste the data */
        memcpy(Buffer + sizeof(guint32), data, len);    
        /* And write it to the socket */
        ret = write(directconn->fd, Buffer, buf_size);

#ifdef DEBUG_DC
        char *str;
        str = g_strdup_printf("%s/msntest/w%.4d.bin", g_get_home_dir(), 
directconn->c);

        FILE *tf = g_fopen(str, "w");
        fwrite(Buffer, 1, buf_size, tf);
        fclose(tf);

        g_free(str);
#endif

        g_free(Buffer);
        directconn->c++;
        return ret;
}

----------------------------------------------------------------------

>Comment By: Stu Tomlinson (nosnilmot)
Date: 2007-02-11 10:33

Message:
Logged In: YES 
user_id=309779
Originator: NO

directconn.c is dead code, not actually called by any other part of the
MSN protocol plugin, so I have a feeling this optimization is a little
premature. btw, we prefer unified diff format, and as files attached to
tracker items instead of inline.

----------------------------------------------------------------------

Comment By: tombcore (tombcore)
Date: 2007-02-11 05:26

Message:
Logged In: YES 
user_id=1716009
Originator: YES

Sorry, this is the first time I submit a patch. This is not a big
improvement, just a sample to see how community devel works.

128a129,130
> 
>       /* Init TCP connection to server */
132d133
< 
145c146,147
< 
---
> 
>       /* Connected, now bind */
166,167c168
< msn_directconn_write(MsnDirectConn *directconn,
<                                        const char *data, size_t len)
---
> msn_directconn_write(MsnDirectConn *directconn, const char *data, size_t
len)
169c170
<       char *buffer, *tmp;
---
>       char *Buffer;
172d172
<       guint32 sent_len;
177,186c177,186
<       buffer = tmp = g_malloc(buf_size);
< 
<       sent_len = GUINT32_TO_LE(len);
< 
<       memcpy(tmp, &sent_len, 4);
<       tmp += 4;
<       memcpy(tmp, data, len);
<       tmp += len;
< 
<       ret = write(directconn->fd, buffer, buf_size);
---
>       Buffer = g_malloc(buf_size);
>       if (Buffer == NULL)
>               return 0;
> 
>       /* Convert len int and paste it at the begining of buffer */
>       *((guint32*)Buffer) = GUINT32_TO_LE(len);
>       /* Then paste the data */
>       memcpy(Buffer + sizeof(guint32), data, len);
>       /* And write it to the socket */
>       ret = write(directconn->fd, Buffer, buf_size);
193,213c193
<       fwrite(buffer, 1, buf_size, tf);
<       fclose(tf);
< 
<       g_free(str);
< #endif
< 
<       g_free(buffer);
< 
< #if 0
<       /* Let's write the length of the data. */
<       ret = write(directconn->fd, &len, sizeof(len));
< 
<       /* Let's write the data. */
<       ret = write(directconn->fd, data, len);
< 
<       char *str;
<       str = g_strdup_printf("/home/revo/msntest/w%.4d.bin",
directconn->c);
< 
<       FILE *tf = g_fopen(str, "w");
<       fwrite(&len, 1, sizeof(len), tf);
<       fwrite(data, 1, len, tf);
---
>       fwrite(Buffer, 1, buf_size, tf);
218a199
>       g_free(Buffer);
220d200
< 
260d239
< 

----------------------------------------------------------------------

Comment By: Richard Laager (rlaager)
Date: 2007-02-10 18:56

Message:
Logged In: YES 
user_id=156487
Originator: NO

What did you change? Can you submit this as a diff instead?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=300235&aid=1656984&group_id=235

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Gaim-patches mailing list
Gaim-patches@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gaim-patches

Reply via email to