Merge: rta: resolve the open-types in a depth-first order to reach limit faster
authorJean Privat <jean@pryen.org>
Sun, 29 May 2016 20:36:02 +0000 (16:36 -0400)
committerJean Privat <jean@pryen.org>
Sun, 29 May 2016 20:36:02 +0000 (16:36 -0400)
Reported-by: Alexandre Terrasa <alexandre@moz-code.org> @Morriar

Pull-Request: #2139
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

lib/core/math.nit
src/catalog.nit
tests/sav/nitcatalog_args1.res

index 0f8325f..7b51e2a 100644 (file)
@@ -169,6 +169,16 @@ redef class Int
                end
                return res
        end
+
+       # Is `self` a power of two ?
+       #
+       # ~~~nit
+       # assert not 3.is_pow2
+       # assert 2.is_pow2
+       # assert 1.is_pow2
+       # assert not 0.is_pow2
+       # ~~~
+       fun is_pow2: Bool do return self != 0 and (self & self - 1) == 0
 end
 
 redef class Byte
index 1743179..92510bc 100644 (file)
@@ -362,8 +362,9 @@ class Catalog
                var doc_score = 0.0
                for g in mpackage.mgroups do
                        mmodules += g.mmodules.length
-                       entity_score += 1.0
-                       if g.mdoc != null then doc_score += 1.0
+                       var gs = 1.0
+                       entity_score += gs
+                       if g.mdoc != null then doc_score += gs
                        for m in g.mmodules do
                                var source = m.location.file
                                if source != null then
@@ -382,21 +383,23 @@ class Catalog
                                                loc += file.line_starts.length - 1
                                        end
                                end
-                               entity_score += 1.0
-                               if m.mdoc != null then doc_score += 1.0
+                               var ms = gs
+                               if m.is_test_suite then ms /= 100.0
+                               entity_score += ms
+                               if m.mdoc != null then doc_score += ms else ms /= 10.0
                                for cd in m.mclassdefs do
-                                       var s = 0.2
-                                       if not cd.is_intro then s /= 10.0
-                                       if not cd.mclass.visibility <= private_visibility then s /= 10.0
-                                       entity_score += s
-                                       if cd.mdoc != null then doc_score += s
+                                       var cs = ms * 0.2
+                                       if not cd.is_intro then cs /= 100.0
+                                       if not cd.mclass.visibility <= private_visibility then cs /= 100.0
+                                       entity_score += cs
+                                       if cd.mdoc != null then doc_score += cs
                                        mclasses += 1
                                        for pd in cd.mpropdefs do
-                                               s = 0.1
-                                               if not pd.is_intro then s /= 10.0
-                                               if not pd.mproperty.visibility <= private_visibility then s /= 10.0
-                                               entity_score += s
-                                               if pd.mdoc != null then doc_score += s
+                                               var ps = ms * 0.1
+                                               if not pd.is_intro then ps /= 100.0
+                                               if not pd.mproperty.visibility <= private_visibility then ps /= 100.0
+                                               entity_score += ps
+                                               if pd.mdoc != null then doc_score += ps
                                                if not pd isa MMethodDef then continue
                                                mmethods += 1
                                        end
index 19b015f..f97fee4 100644 (file)
@@ -76,7 +76,7 @@
 <h3>Quality</h3>
 <ul class="box">
 <li>28 warnings (63/kloc)</li>
-<li>93% documented</li>
+<li>95% documented</li>
 </ul>
 <h3>Tags</h3>
 <a href="../index.html#tag_test">test</a>, <a href="../index.html#tag_game">game</a><h3>Requirements</h3>