[hackers] [surf] Improve parameters handling || Quentin Rameau

From: <git_AT_suckless.org>
Date: Thu, 11 May 2017 16:33:12 +0200 (CEST)

commit 745a319bafd6ff0702c37d0333142ca18e801a4a
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Tue May 9 14:45:24 2017 +0200
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Thu May 11 09:22:43 2017 +0200

    Improve parameters handling
    
    There's no need to reload all parameters each time a new url is loaded,
    instead set only custom parameters and restore those to defaults when
    needed.

diff --git a/surf.c b/surf.c
index 0fcf22e..57c4c22 100644
--- a/surf.c
+++ b/surf.c
_AT_@ -636,18 +636,32 @@ cookiepolicy_set(const WebKitCookieAcceptPolicy p)
 void
 seturiparameters(Client *c, const char *uri)
 {
+ Parameter *newconfig = NULL;
         int i;
 
         for (i = 0; i < LENGTH(uriparams); ++i) {
                 if (uriparams[i].uri &&
                     !regexec(&(uriparams[i].re), uri, 0, NULL, 0)) {
- curconfig = uriparams[i].config;
+ newconfig = uriparams[i].config;
                         break;
                 }
         }
 
- for (i = 0; i < ParameterLast; ++i)
- setparameter(c, 0, i, &curconfig[i].val);
+ if (!newconfig)
+ newconfig = defconfig;
+ if (newconfig == curconfig)
+ return;
+
+ for (i = 0; i < ParameterLast; ++i) {
+ if (defconfig[i].force)
+ continue;
+ if (newconfig[i].force)
+ setparameter(c, 0, i, &newconfig[i].val);
+ else if (curconfig[i].force)
+ setparameter(c, 0, i, &defconfig[i].val);
+ }
+
+ curconfig = newconfig;
 }
 
 void
_AT_@ -1350,7 +1364,6 @@ loadchanged(WebKitWebView *v, WebKitLoadEvent e, Client *c)
 
         switch (e) {
         case WEBKIT_LOAD_STARTED:
- curconfig = defconfig;
                 setatom(c, AtomUri, title);
                 c->title = title;
                 c->https = c->insecure = 0;
Received on Thu May 11 2017 - 16:33:12 CEST

This archive was generated by hypermail 2.3.0 : Thu May 11 2017 - 16:36:23 CEST