Skip to content

Commit

Permalink
[Minor] Save 8 bytes in rspamd_regexp_t
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Aug 24, 2021
1 parent 1e73c00 commit f3b23bc
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 39 deletions.
29 changes: 0 additions & 29 deletions src/libutil/regexp.c
Expand Up @@ -71,7 +71,6 @@ struct rspamd_regexp_s {
gint flags;
gint pcre_flags;
gint ncaptures;
gint nbackref;
};

struct rspamd_regexp_cache {
Expand Down Expand Up @@ -516,24 +515,12 @@ rspamd_regexp_new_len (const gchar *pattern, gsize len, const gchar *flags,
&ncaptures) == 0) {
res->ncaptures = ncaptures;
}

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

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

return res;
Expand Down Expand Up @@ -838,22 +825,6 @@ rspamd_regexp_get_pcre_flags (const rspamd_regexp_t *re)
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
rspamd_regexp_get_maxhits (const rspamd_regexp_t *re)
{
Expand Down
10 changes: 0 additions & 10 deletions src/libutil/regexp.h
Expand Up @@ -161,16 +161,6 @@ guint rspamd_regexp_get_maxhits (const rspamd_regexp_t *re);
*/
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
*/
Expand Down

0 comments on commit f3b23bc

Please sign in to comment.