Quellcode durchsuchen

[Minor] Save 8 bytes in rspamd_regexp_t

tags/3.1
Vsevolod Stakhov vor 2 Jahren
Ursprung
Commit
f3b23bccaf
2 geänderte Dateien mit 0 neuen und 39 gelöschten Zeilen
  1. 0
    29
      src/libutil/regexp.c
  2. 0
    10
      src/libutil/regexp.h

+ 0
- 29
src/libutil/regexp.c Datei anzeigen

gint flags; gint flags;
gint pcre_flags; gint pcre_flags;
gint ncaptures; gint ncaptures;
gint nbackref;
}; };


struct rspamd_regexp_cache { struct rspamd_regexp_cache {
&ncaptures) == 0) { &ncaptures) == 0) {
res->ncaptures = ncaptures; res->ncaptures = ncaptures;
} }

/* Check number of backrefs */
if (pcre_fullinfo (res->raw_re, res->extra, PCRE_INFO_BACKREFMAX,
&ncaptures) == 0) {
res->nbackref = ncaptures;
}
#else #else
/* Check number of captures */ /* Check number of captures */
if (pcre2_pattern_info (res->raw_re, PCRE2_INFO_CAPTURECOUNT, if (pcre2_pattern_info (res->raw_re, PCRE2_INFO_CAPTURECOUNT,
&ncaptures) == 0) { &ncaptures) == 0) {
res->ncaptures = ncaptures; res->ncaptures = ncaptures;
} }

/* Check number of backrefs */
if (pcre2_pattern_info (res->raw_re, PCRE2_INFO_BACKREFMAX,
&ncaptures) == 0) {
res->nbackref = ncaptures;
}
#endif #endif


return res; return res;
return re->pcre_flags; return re->pcre_flags;
} }


gint
rspamd_regexp_get_nbackrefs (const rspamd_regexp_t *re)
{
g_assert (re != NULL);

return re->nbackref;
}

gint
rspamd_regexp_get_ncaptures (const rspamd_regexp_t *re)
{
g_assert (re != NULL);

return re->ncaptures;
}

guint guint
rspamd_regexp_get_maxhits (const rspamd_regexp_t *re) rspamd_regexp_get_maxhits (const rspamd_regexp_t *re)
{ {

+ 0
- 10
src/libutil/regexp.h Datei anzeigen

*/ */
guint rspamd_regexp_set_maxhits (rspamd_regexp_t *re, guint new_maxhits); guint rspamd_regexp_set_maxhits (rspamd_regexp_t *re, guint new_maxhits);


/**
* Returns number of backreferences in a regexp
*/
gint rspamd_regexp_get_nbackrefs (const rspamd_regexp_t *re);

/**
* Returns number of capture groups in a regexp
*/
gint rspamd_regexp_get_ncaptures (const rspamd_regexp_t *re);

/** /**
* Returns cache id for a regexp * Returns cache id for a regexp
*/ */

Laden…
Abbrechen
Speichern