Simplify rules display property assignment - surf-adblock - Surf adblock web extension
 (HTM) git clone git://git.codemadness.org/surf-adblock
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit fd00cc5304e3e118f4c692cede055cd2baf62307
 (DIR) parent 45bbe933e712772b3f1513c8a8970b7e2743f07c
 (HTM) Author: Quentin Rameau <quinq@fifth.space>
       Date:   Sat,  3 Jun 2017 22:12:31 +0200
       
       Simplify rules display property assignment
       
       Diffstat:
         M surf-adblock.c                      |      14 +++++---------
       
       1 file changed, 5 insertions(+), 9 deletions(-)
       ---
 (DIR) diff --git a/surf-adblock.c b/surf-adblock.c
       @@ -812,19 +812,15 @@ documentloaded(WebKitWebPage *wp, Page *p)
                for (r = rules; r; r = r->next) {
                        if (!r->css || !r->domains || !matchrule(r, "", "", domain))
                                continue;
       +
                        len = strlen(r->css);
                        if (string_append(&sitecss, r->css, len) < len)
                                return;
        
       -                if (r->isexception) {
       -                        len = sizeof("{display:initial;}") -1;
       -                        if (string_append(&sitecss, "{display:initial;}", len) < len)
       -                                return;
       -                } else {
       -                        len = sizeof("{display:none;}") -1;
       -                        if (string_append(&sitecss, "{display:none;}", len) < len)
       -                                return;
       -                }
       +                s = r->isexception ? "{display:initial;}" : "{display:none;}";
       +                len = strlen(s);
       +                if (string_append(&sitecss, s, len) < len)
       +                        return;
                }
        /*        printf("sitecss: %s\n", sitecss.data ? sitecss.data : "<empty>");*/