Merge: parser: do not allocate a reduction table for each parser
authorJean Privat <jean@pryen.org>
Tue, 20 Oct 2015 00:23:44 +0000 (20:23 -0400)
committerJean Privat <jean@pryen.org>
Tue, 20 Oct 2015 00:23:44 +0000 (20:23 -0400)
This optimize multiple Parser allocation, for instance nitunit or nitdoc that need to deal with each nitunit in the documentation.

usertime for `./nitdoc ../lib/core/`:

* before: 0m2.184s
* after: 0m1.788s (-18.1%)

Pull-Request: #1770
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

contrib/opportunity/src/templates/meetup.nit
lib/html/html.nit

index 0358f33..043c86b 100644 (file)
@@ -211,7 +211,11 @@ class OpportunityMeetupPage
                                .fail(function(data){
                                        //TODO: Notify of failure
                                });
+
+                       // Remember the participant's name client-side
+                       set_cookie("opportunity_participant_name", pname);
                }
+
                function remove_people(ele){
                        var arr = ele.id.split("_")
                        var pid = arr[1]
@@ -226,6 +230,7 @@ class OpportunityMeetupPage
                                }
                        });
                }
+
                // ID of line currently open for modification
                var in_modification_id = null;
                function modify_people(ele, id){
@@ -248,6 +253,30 @@ class OpportunityMeetupPage
                                in_modification_id = null;
                        }
                }
+
+               function get_cookie(cookie_name) {
+                   var name = cookie_name + "=";
+                       var ca = document.cookie.split(';');
+                       for(var i = 0; i < ca.length; i ++) {
+                               var c = ca[i];
+                               while (c.charAt(0) == ' ') c = c.substring(1);
+                               if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
+                       }
+                       return "";
+               }
+
+               function set_cookie(cookie_name, value) {
+                   var date = new Date();
+                       date.setTime(date.getTime() + (365*24*60*60*1000));
+                       var expires = "expires="+date.toUTCString();
+                       document.cookie = cookie_name + "=" + value + "; " + expires;
+               }
+
+               // Retrieve the last client-side participant's name
+               window.onload = function () {
+                       var name_field = document.getElementById("new_name");
+                       name_field.value = get_cookie("opportunity_participant_name");
+               }
                """
        end
 
index d3a92eb..72284ef 100644 (file)
@@ -107,7 +107,12 @@ class HTMLTag
        # `"div"` for `<div></div>`.
        var tag: String
        init do
-               self.is_void = (once ["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]).has(tag)
+               self.is_void = (once void_list).has(tag)
+       end
+
+       private fun void_list: Set[String]
+       do
+               return new HashSet[String].from(["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"])
        end
 
        # Is the HTML element a void element?