Remove redundancy
authorDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Wed, 24 Feb 2016 21:22:26 +0000 (22:22 +0100)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Wed, 24 Feb 2016 21:22:26 +0000 (22:22 +0100)
python/helpers/pydev/_pydevd_bundle/pydevd_signature.py

index 5af54c8098a37c5eae85c7e99f2a4e054ccbde24..98b660f4ff51528aa03647e8df5b4366eaa9bffd 100644 (file)
@@ -133,21 +133,13 @@ class CallSignatureCache(object):
 
     def add(self, signature):
         filename, name, args_type = get_signature_info(signature)
-
-        if not filename in self.cache:
-            self.cache[filename] = {}
-
-        calls_from_file = self.cache[filename]
-
-        if not name in calls_from_file:
-            calls_from_file[name] = {}
-
-        name_calls = calls_from_file[name]
+        calls_from_file = self.cache.setdefault(filename, {})
+        name_calls = calls_from_file.setdefault(name, {})
         name_calls[args_type] = None
 
     def is_in_cache(self, signature):
         filename, name, args_type = get_signature_info(signature)
-        if filename in self.cache and name in self.cache[filename] and args_type in self.cache[filename][name]:
+        if args_type in self.cache.get(filename, {}).get(name, {}):
             return True
         return False