From patchwork Thu Aug 8 13:16:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1, of, 2] hgweb: eliminate extra complexity in process_dates definition From: Alexander Plavin X-Patchwork-Id: 2095 Message-Id: To: mercurial-devel@selenic.com Date: Thu, 08 Aug 2013 17:16:56 +0400 # HG changeset patch # User Alexander Plavin # Date 1374677635 -14400 # Wed Jul 24 18:53:55 2013 +0400 # Node ID d2e91a2d576deff3bb97fefc1fe71c2a64d64bb6 # Parent f0f7f831444ba82f8547dabd4a47bb502232b4d2 hgweb: eliminate extra complexity in process_dates definition There was an extra anonymous outer function, called immediately. It is removed in this patch. diff -r f0f7f831444b -r d2e91a2d576d mercurial/templates/static/mercurial.js --- a/mercurial/templates/static/mercurial.js Wed Jul 24 03:20:26 2013 +0400 +++ b/mercurial/templates/static/mercurial.js Wed Jul 24 18:53:55 2013 +0400 @@ -168,7 +168,7 @@ } -process_dates = (function(document, RegExp, Math, isNaN, Date, _false, _true){ +function process_dates(){ // derived from code from mercurial/templatefilter.py @@ -219,9 +219,9 @@ var delta = Math.floor((now.getTime() - once.getTime()) / 1000); - var future = _false; + var future = false; if (delta < 0){ - future = _true; + future = true; delta = -delta; if (delta > (30 * scales.year)){ return "in the distant future"; @@ -245,26 +245,24 @@ } } - return function(){ - var nodes = document.getElementsByTagName('*'); - var ageclass = new RegExp('\\bage\\b'); - var dateclass = new RegExp('\\bdate\\b'); - for (var i=0; i