Auto merge of #7199 - frewsxcv:codegen-if-let, r=Manishearth

Prefer if..let over if..is_some..unwrap in codegen



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7199)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-08-13 15:35:21 -06:00
commit 2e1ca10eea

View file

@ -4034,8 +4034,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
'successCode': fillDescriptor,
'pre': 'let mut result_root = RootedValue::new(cx, UndefinedValue());'
}
get += ("if index.is_some() {\n" +
" let index = index.unwrap();\n" +
get += ("if let Some(index) = index {\n" +
" let this = UnwrapProxy(proxy);\n" +
" let this = &*this;\n" +
CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define() + "\n" +
@ -4104,8 +4103,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
if not (self.descriptor.operations['IndexedCreator'] is indexedSetter):
raise TypeError("Can't handle creator that's different from the setter")
set += ("let index = get_array_index_from_id(cx, id);\n" +
"if index.is_some() {\n" +
" let index = index.unwrap();\n" +
"if let Some(index) = index {\n" +
" let this = UnwrapProxy(proxy);\n" +
" let this = &*this;\n" +
CGIndenter(CGProxyIndexedSetter(self.descriptor)).define() +
@ -4188,8 +4186,7 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
indexedGetter = self.descriptor.operations['IndexedGetter']
if indexedGetter:
indexed = ("let index = get_array_index_from_id(cx, id);\n" +
"if index.is_some() {\n" +
" let index = index.unwrap();\n" +
"if let Some(index) = index {\n" +
" let this = UnwrapProxy(proxy);\n" +
" let this = &*this;\n" +
CGIndenter(CGProxyIndexedGetter(self.descriptor)).define() + "\n" +
@ -4261,8 +4258,7 @@ if !expando.ptr.is_null() {
indexedGetter = self.descriptor.operations['IndexedGetter']
if indexedGetter:
getIndexedOrExpando = ("let index = get_array_index_from_id(cx, id);\n" +
"if index.is_some() {\n" +
" let index = index.unwrap();\n" +
"if let Some(index) = index {\n" +
" let this = UnwrapProxy(proxy);\n" +
" let this = &*this;\n" +
CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define())