Title: [183281] trunk/Tools
- Revision
- 183281
- Author
- [email protected]
- Date
- 2015-04-24 14:39:06 -0700 (Fri, 24 Apr 2015)
Log Message
Cleanup: Use @memoized for property IOSSimulator.testing_device
https://bugs.webkit.org/show_bug.cgi?id=141715
Reviewed by Darin Adler.
Simplify the caching of the result of IOSSimulator.testing_device
and make the code more readable by making use of the @memoized declarator
instead of explicitly managing a private instance variable,
IOSSimulator._testing_device, for the cached result.
* Scripts/webkitpy/port/ios.py:
(IOSPort.determine_full_port_name):
(IOSSimulatorPort.__init__): Delete instance variable IOSSimulatorPort._testing_device.
(IOSSimulatorPort):
(IOSSimulatorPort.testing_device): No need to cache the created device object in
IOSSimulatorPort._testing_device since we are marking this function @memoized.
(IOSSimulatorPort.reset_preferences): Code style fix; inline self.testing_device.path instead
of caching in local variable since we only make use of this value exactly once in this function.
(IOSPort.__init__): Deleted; The instance variable IOSPort._testing_device has never
been used since being added in r178622. So, we can remove this constructor since
it's the trivial constructor once we remove the instance variable IOSPort._testing_device.
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (183280 => 183281)
--- trunk/Tools/ChangeLog 2015-04-24 21:09:02 UTC (rev 183280)
+++ trunk/Tools/ChangeLog 2015-04-24 21:39:06 UTC (rev 183281)
@@ -1,3 +1,27 @@
+2015-04-24 Daniel Bates <[email protected]>
+
+ Cleanup: Use @memoized for property IOSSimulator.testing_device
+ https://bugs.webkit.org/show_bug.cgi?id=141715
+
+ Reviewed by Darin Adler.
+
+ Simplify the caching of the result of IOSSimulator.testing_device
+ and make the code more readable by making use of the @memoized declarator
+ instead of explicitly managing a private instance variable,
+ IOSSimulator._testing_device, for the cached result.
+
+ * Scripts/webkitpy/port/ios.py:
+ (IOSPort.determine_full_port_name):
+ (IOSSimulatorPort.__init__): Delete instance variable IOSSimulatorPort._testing_device.
+ (IOSSimulatorPort):
+ (IOSSimulatorPort.testing_device): No need to cache the created device object in
+ IOSSimulatorPort._testing_device since we are marking this function @memoized.
+ (IOSSimulatorPort.reset_preferences): Code style fix; inline self.testing_device.path instead
+ of caching in local variable since we only make use of this value exactly once in this function.
+ (IOSPort.__init__): Deleted; The instance variable IOSPort._testing_device has never
+ been used since being added in r178622. So, we can remove this constructor since
+ it's the trivial constructor once we remove the instance variable IOSPort._testing_device.
+
2015-04-24 Anders Carlsson <[email protected]>
Rename -[WKWebsiteDataStore isNonPersistent] to -[WKWebsiteDataStore isPersistent]
Modified: trunk/Tools/Scripts/webkitpy/port/ios.py (183280 => 183281)
--- trunk/Tools/Scripts/webkitpy/port/ios.py 2015-04-24 21:09:02 UTC (rev 183280)
+++ trunk/Tools/Scripts/webkitpy/port/ios.py 2015-04-24 21:39:06 UTC (rev 183281)
@@ -60,11 +60,6 @@
port_name = port_name + '-' + major_version_number
return port_name
- def __init__(self, *args, **kwargs):
- super(IOSPort, self).__init__(*args, **kwargs)
-
- self._testing_device = None
-
# Despite their names, these flags do not actually get passed all the way down to webkit-build.
def _build_driver_flags(self):
return ['--sdk', 'iphoneos'] + (['ARCHS=%s' % self.architecture()] if self.architecture() else [])
@@ -93,8 +88,6 @@
# with MallocStackLogging enabled.
self.set_option_default("batch_size", 1000)
- self._testing_device = None
-
def driver_name(self):
if self.get_option('driver_name'):
return self.get_option('driver_name')
@@ -328,11 +321,9 @@
return stderr, crash_log
@property
+ @memoized
def testing_device(self):
- if self._testing_device is not None:
- return self._testing_device
- self._testing_device = Simulator().lookup_or_create_device(self.simulator_device_type.name + ' WebKit Tester', self.simulator_device_type, self.simulator_runtime)
- return self.testing_device
+ return Simulator().lookup_or_create_device(self.simulator_device_type.name + ' WebKit Tester', self.simulator_device_type, self.simulator_runtime)
def look_for_new_crash_logs(self, crashed_processes, start_time):
crash_logs = {}
@@ -385,8 +376,7 @@
return self._image_differ.diff_image(expected_contents, actual_contents, tolerance)
def reset_preferences(self):
- simulator_path = self.testing_device.path
- data_path = os.path.join(simulator_path, 'data')
+ data_path = os.path.join(self.testing_device.path, 'data')
if os.path.isdir(data_path):
shutil.rmtree(data_path)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes