From Kovarththanan Rajaratnam:

Optimize column fill path.
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=3701

svn path=/trunk/; revision=29130
This commit is contained in:
Anders Broman 2009-07-17 08:24:06 +00:00
parent f9177273d8
commit 3278582767
3 changed files with 19 additions and 23 deletions

View File

@ -2633,11 +2633,11 @@ const gchar *get_addr_name(address *addr)
} /* get_addr_name */
void get_addr_name_buf(address *addr, gchar *buf, guint size)
void get_addr_name_buf(address *addr, gchar *buf, gsize size)
{
const gchar *result = get_addr_name(addr);
g_snprintf(buf, size, "%s", result);
g_strlcpy(buf, result, size);
} /* get_addr_name_buf */

View File

@ -113,7 +113,7 @@ const gchar *get_addr_name(address *addr);
/* the result which is always NUL ('\0') terminated. The buffer should be large enough to */
/* contain size characters including the terminator */
void get_addr_name_buf(address *addr, gchar *buf, guint size);
void get_addr_name_buf(address *addr, gchar *buf, gsize size);
/*

View File

@ -583,42 +583,39 @@ void
display_signed_time(gchar *buf, int buflen, gint32 sec, gint32 frac,
time_res_t units)
{
const char *sign;
/* If the fractional part of the time stamp is negative,
print its absolute value and, if the seconds part isn't
(the seconds part should be zero in that case), stick
a "-" in front of the entire time stamp. */
sign = "";
if (frac < 0) {
frac = -frac;
if (sec >= 0)
sign = "-";
}
buf[0] = '-';
++buf; }
switch (units) {
case SECS:
g_snprintf(buf, buflen, "%s%d", sign, sec);
g_snprintf(buf, buflen, "%d", sec);
break;
case DSECS:
g_snprintf(buf, buflen, "%s%d.%01d", sign, sec, frac);
g_snprintf(buf, buflen, "%d.%01d", sec, frac);
break;
case CSECS:
g_snprintf(buf, buflen, "%s%d.%02d", sign, sec, frac);
g_snprintf(buf, buflen, "%d.%02d", sec, frac);
break;
case MSECS:
g_snprintf(buf, buflen, "%s%d.%03d", sign, sec, frac);
g_snprintf(buf, buflen, "%d.%03d", sec, frac);
break;
case USECS:
g_snprintf(buf, buflen, "%s%d.%06d", sign, sec, frac);
g_snprintf(buf, buflen, "%d.%06d", sec, frac);
break;
case NSECS:
g_snprintf(buf, buflen, "%s%d.%09d", sign, sec, frac);
g_snprintf(buf, buflen, "%d.%09d", sec, frac);
break;
}
}
@ -628,7 +625,6 @@ void
display_epoch_time(gchar *buf, int buflen, time_t sec, gint32 frac,
time_res_t units)
{
const char *sign;
double elapsed_secs;
elapsed_secs = difftime(sec,(time_t)0);
@ -639,36 +635,36 @@ display_epoch_time(gchar *buf, int buflen, time_t sec, gint32 frac,
print its absolute value and, if the seconds part isn't
(the seconds part should be zero in that case), stick
a "-" in front of the entire time stamp. */
sign = "";
if (frac < 0) {
frac = -frac;
if (elapsed_secs >= 0)
sign = "-";
buf[0] = '-';
++buf;
}
switch (units) {
case SECS:
g_snprintf(buf, buflen, "%s%0.0f", sign, elapsed_secs);
g_snprintf(buf, buflen, "%0.0f", elapsed_secs);
break;
case DSECS:
g_snprintf(buf, buflen, "%s%0.0f.%01d", sign, elapsed_secs, frac);
g_snprintf(buf, buflen, "%0.0f.%02d", elapsed_secs, frac);
break;
case CSECS:
g_snprintf(buf, buflen, "%s%0.0f.%02d", sign, elapsed_secs, frac);
g_snprintf(buf, buflen, "%0.0f.%02d", elapsed_secs, frac);
break;
case MSECS:
g_snprintf(buf, buflen, "%s%0.0f.%03d", sign, elapsed_secs, frac);
g_snprintf(buf, buflen, "%0.0f.%03d", elapsed_secs, frac);
break;
case USECS:
g_snprintf(buf, buflen, "%s%0.0f.%06d", sign, elapsed_secs, frac);
g_snprintf(buf, buflen, "%0.0f.%06d", elapsed_secs, frac);
break;
case NSECS:
g_snprintf(buf, buflen, "%s%0.0f.%09d", sign, elapsed_secs, frac);
g_snprintf(buf, buflen, "%0.0f.%09d", elapsed_secs, frac);
break;
}
}