xC: mildly optimize relay traffic
This commit is contained in:
parent
b2b3093e0e
commit
d31ab67268
16
xC.c
16
xC.c
@ -1541,6 +1541,7 @@ struct formatter
|
|||||||
struct app_context *ctx; ///< Application context
|
struct app_context *ctx; ///< Application context
|
||||||
struct server *s; ///< Server
|
struct server *s; ///< Server
|
||||||
|
|
||||||
|
bool clean; ///< Assume ATTR_RESET
|
||||||
struct formatter_item *items; ///< Items
|
struct formatter_item *items; ///< Items
|
||||||
size_t items_len; ///< Items used
|
size_t items_len; ///< Items used
|
||||||
size_t items_alloc; ///< Items allocated
|
size_t items_alloc; ///< Items allocated
|
||||||
@ -1549,7 +1550,7 @@ struct formatter
|
|||||||
static struct formatter
|
static struct formatter
|
||||||
formatter_make (struct app_context *ctx, struct server *s)
|
formatter_make (struct app_context *ctx, struct server *s)
|
||||||
{
|
{
|
||||||
struct formatter self = { .ctx = ctx, .s = s };
|
struct formatter self = { .ctx = ctx, .s = s, .clean = true };
|
||||||
self.items = xcalloc (sizeof *self.items, (self.items_alloc = 16));
|
self.items = xcalloc (sizeof *self.items, (self.items_alloc = 16));
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -3811,7 +3812,7 @@ irc_to_utf8 (const char *text)
|
|||||||
// #d inserts a signed integer
|
// #d inserts a signed integer
|
||||||
// #l inserts a locale-encoded string
|
// #l inserts a locale-encoded string
|
||||||
//
|
//
|
||||||
// #S inserts a string from the server with unknown encoding
|
// #S inserts a string from the server in an unknown encoding
|
||||||
// #m inserts an IRC-formatted string (auto-resets at boundaries)
|
// #m inserts an IRC-formatted string (auto-resets at boundaries)
|
||||||
// #n cuts the nickname from a string and automatically colours it
|
// #n cuts the nickname from a string and automatically colours it
|
||||||
// #N is like #n but also appends userhost, if present
|
// #N is like #n but also appends userhost, if present
|
||||||
@ -3827,6 +3828,17 @@ irc_to_utf8 (const char *text)
|
|||||||
static void
|
static void
|
||||||
formatter_add_item (struct formatter *self, struct formatter_item template_)
|
formatter_add_item (struct formatter *self, struct formatter_item template_)
|
||||||
{
|
{
|
||||||
|
// Auto-resetting tends to create unnecessary items,
|
||||||
|
// which also end up being relayed to frontends, so filter them out.
|
||||||
|
bool reset =
|
||||||
|
template_.type == FORMATTER_ITEM_ATTR &&
|
||||||
|
template_.attribute == ATTR_RESET;
|
||||||
|
if (self->clean && reset)
|
||||||
|
return;
|
||||||
|
|
||||||
|
self->clean = reset ||
|
||||||
|
(self->clean && template_.type == FORMATTER_ITEM_TEXT);
|
||||||
|
|
||||||
if (template_.text)
|
if (template_.text)
|
||||||
template_.text = xstrdup (template_.text);
|
template_.text = xstrdup (template_.text);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user