This is an automated email from the ASF dual-hosted git repository.

harbs pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new 9853255  Cleaned up and documented ObjectMap
9853255 is described below

commit 9853255a0b78401971e1b28f06954ef0453a8d23
Author: Harbs <[email protected]>
AuthorDate: Sat Feb 24 22:53:37 2018 +0200

    Cleaned up and documented ObjectMap
---
 .../royale/org/apache/royale/utils/ObjectMap.as    | 111 +++++++++++++++------
 1 file changed, 81 insertions(+), 30 deletions(-)

diff --git 
a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/ObjectMap.as 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/ObjectMap.as
index 256e8e1..d3bd5bc 100644
--- 
a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/ObjectMap.as
+++ 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/ObjectMap.as
@@ -28,6 +28,17 @@ package org.apache.royale.utils
     {
         import org.apache.royale.utils.UIDUtil;
     }
+    /**
+     *  The ObjectMap class is a hash class which supports weak keys
+     *  and object keys on systems which support it. This includes Flash
+     *  and most modern browsers. For browsers which do not support Map and 
WeakMap,
+     *  it falls back to simple object hashes.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Royale 0.9.1
+     */
 
     public class ObjectMap
     {
@@ -40,64 +51,104 @@ package org.apache.royale.utils
             }
             COMPILE::JS
             {
-                if(weak)
-                {
-                    if(typeof WeakMap == "function")
-                    {
-                        _map = new WeakMap();
-                        assignFunctions();
-                    }
-                    else if(typeof Map == "function")//Map is supported, fall 
back to that
-                    {
-                        _map = new Map();
-                        assignFunctions();
-                        _weak = false;
-                    }
-                    else
-                    {
-                        _map = {};
-                        _usesObjects = true;
-                    }
-                }
-                else if(typeof Map == "function")
-                {
-                    _map = new Map();
-                    assignFunctions();
-                }
-                else
-                {
-                    _map = {};
-                    _usesObjects = true;
-                    assignFunctions();
-                }
+                makeMap();
             }
+        }
 
+        COMPILE::JS
+        private function makeMap():void
+        {
+            if(_weak && typeof WeakMap == "function")
+            {
+                _map = new WeakMap();
+                assignFunctions();
+                return;
+            }
+            _weak = false;
+            if(typeof Map == "function")
+            {
+                _map = new Map();
+                assignFunctions();
+            }
+            else
+            {
+                _map = {};
+                _usesObjects = true;
+            }
         }
+
         private var _weak:Boolean;
         private var _map:Object;
         private var _usesObjects:Boolean = false;
 
+        /**
+         *  Removes the specified key
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.7.0
+         * 
+         */
         COMPILE::SWF
         public function delete(key:Object):void
         {
             delete _map[key];
         }
 
+        /**
+         *  Returns the value associated with the `key`, or `undefined`.
+         * 
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.7.0
+         * 
+         */
         COMPILE::SWF
         public function get(key:Object):*
         {
             return _map[key];
         }
+
+        /**
+         *  Returns whether the key has a value or not.
+         * 
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.7.0
+         * 
+         */
         COMPILE::SWF
         public function has(key:Object):Boolean
         {
             return _map[key] === undefined;
         }
+
+        /**
+         *  Sets the value for the specified key.
+         * 
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.7.0
+         * 
+         */
         COMPILE::SWF
         public function set(key:Object,value:*):void
         {
             _map[key] = value;
         }
+
+        /**
+         *  Removes all key/value pairs.
+         * 
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.7.0
+         * 
+         */
         COMPILE::SWF
         public function clear():void
         {

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to