Use autoreleased methods to create NSMutableDictionary and NSNumber objects instead of +1 retained methods. * TestWebKitAPI/Tests/WebKit2Cocoa/PluginLoadClientPolicies.mm: (TEST):
Created attachment 313638 [details] Patch v1
Created attachment 313646 [details] Patch v2
Comment on attachment 313646 [details] Patch v2 View in context: https://bugs.webkit.org/attachment.cgi?id=313646&action=review > Tools/TestWebKitAPI/Tests/WebKit2Cocoa/PluginLoadClientPolicies.mm:71 > + RetainPtr<NSMutableDictionary> newPolicies = adoptNS([policies mutableCopy]); r=me, but I find this way harder to read. How about switching to ObjC literal syntax? You'd end up with something like: RetainPtr<NSMutableDictionary> newPolicies = adoptNS([policies mutableCopy]); [newPolicies removeObjectForKey:@"apple.com"]; newPolicies.get()[@"google.com"] = @{ @"com.macromedia.Flash Player.plugin": @{ @"26.0.0.126": @(kWKPluginLoadClientPolicyAllowAlways), }, @"com.apple.QuickTime.plugin": @{ @"1.0": @(kWKPluginLoadClientPolicyBlock), @"1.1": @(kWKPluginLoadClientPolicyAllow), }, };
Comment on attachment 313646 [details] Patch v2 View in context: https://bugs.webkit.org/attachment.cgi?id=313646&action=review >> Tools/TestWebKitAPI/Tests/WebKit2Cocoa/PluginLoadClientPolicies.mm:71 >> + RetainPtr<NSMutableDictionary> newPolicies = adoptNS([policies mutableCopy]); > > r=me, but I find this way harder to read. > > How about switching to ObjC literal syntax? You'd end up with something like: > > RetainPtr<NSMutableDictionary> newPolicies = adoptNS([policies mutableCopy]); > [newPolicies removeObjectForKey:@"apple.com"]; > newPolicies.get()[@"google.com"] = @{ > @"com.macromedia.Flash Player.plugin": @{ > @"26.0.0.126": @(kWKPluginLoadClientPolicyAllowAlways), > }, > @"com.apple.QuickTime.plugin": @{ > @"1.0": @(kWKPluginLoadClientPolicyBlock), > @"1.1": @(kWKPluginLoadClientPolicyAllow), > }, > }; I like this better, but it has the (slight) disadvantage of putting all the objects in an autoreleasepool. I'll switch to adoptNS().get() instead, as we talked about in person.
Committed r218719: <http://trac.webkit.org/changeset/218719>
Comment on attachment 313646 [details] Patch v2 View in context: https://bugs.webkit.org/attachment.cgi?id=313646&action=review >>> Tools/TestWebKitAPI/Tests/WebKit2Cocoa/PluginLoadClientPolicies.mm:71 >>> + RetainPtr<NSMutableDictionary> newPolicies = adoptNS([policies mutableCopy]); >> >> r=me, but I find this way harder to read. >> >> How about switching to ObjC literal syntax? You'd end up with something like: >> >> RetainPtr<NSMutableDictionary> newPolicies = adoptNS([policies mutableCopy]); >> [newPolicies removeObjectForKey:@"apple.com"]; >> newPolicies.get()[@"google.com"] = @{ >> @"com.macromedia.Flash Player.plugin": @{ >> @"26.0.0.126": @(kWKPluginLoadClientPolicyAllowAlways), >> }, >> @"com.apple.QuickTime.plugin": @{ >> @"1.0": @(kWKPluginLoadClientPolicyBlock), >> @"1.1": @(kWKPluginLoadClientPolicyAllow), >> }, >> }; > > I like this better, but it has the (slight) disadvantage of putting all the objects in an autoreleasepool. > > I'll switch to adoptNS().get() instead, as we talked about in person. Readability seems *so* much more important than putting a few objects into the autorelease pool.