Discussion:
[ gaim-Patches-1656984 ] little speed improvement in msn plugin
SourceForge.net
2007-02-26 03:20:08 UTC
Permalink
Patches item #1656984, was opened at 2007-02-10 14:25
Message generated for change (Comment added) made by sf-robot
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: Closed
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: SourceForge Robot (sf-robot)
Date: 2007-02-25 19:20

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

This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).

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

Comment By: Mark Doliner (thekingant)
Date: 2007-02-11 11:16

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

Ooh, and we usually avoid variable names with uppercase letters.
"buffer2" would be a better choice than "Buffer"

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

Comment By: Stu Tomlinson (nosnilmot)
Date: 2007-02-11 07: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 02: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 15: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

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Loading...