mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
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:
commit
2e1ca10eea
1 changed files with 4 additions and 8 deletions
|
@ -4034,8 +4034,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
||||||
'successCode': fillDescriptor,
|
'successCode': fillDescriptor,
|
||||||
'pre': 'let mut result_root = RootedValue::new(cx, UndefinedValue());'
|
'pre': 'let mut result_root = RootedValue::new(cx, UndefinedValue());'
|
||||||
}
|
}
|
||||||
get += ("if index.is_some() {\n" +
|
get += ("if let Some(index) = index {\n" +
|
||||||
" let index = index.unwrap();\n" +
|
|
||||||
" let this = UnwrapProxy(proxy);\n" +
|
" let this = UnwrapProxy(proxy);\n" +
|
||||||
" let this = &*this;\n" +
|
" let this = &*this;\n" +
|
||||||
CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define() + "\n" +
|
CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define() + "\n" +
|
||||||
|
@ -4104,8 +4103,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
||||||
if not (self.descriptor.operations['IndexedCreator'] is indexedSetter):
|
if not (self.descriptor.operations['IndexedCreator'] is indexedSetter):
|
||||||
raise TypeError("Can't handle creator that's different from the setter")
|
raise TypeError("Can't handle creator that's different from the setter")
|
||||||
set += ("let index = get_array_index_from_id(cx, id);\n" +
|
set += ("let index = get_array_index_from_id(cx, id);\n" +
|
||||||
"if index.is_some() {\n" +
|
"if let Some(index) = index {\n" +
|
||||||
" let index = index.unwrap();\n" +
|
|
||||||
" let this = UnwrapProxy(proxy);\n" +
|
" let this = UnwrapProxy(proxy);\n" +
|
||||||
" let this = &*this;\n" +
|
" let this = &*this;\n" +
|
||||||
CGIndenter(CGProxyIndexedSetter(self.descriptor)).define() +
|
CGIndenter(CGProxyIndexedSetter(self.descriptor)).define() +
|
||||||
|
@ -4188,8 +4186,7 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
|
||||||
indexedGetter = self.descriptor.operations['IndexedGetter']
|
indexedGetter = self.descriptor.operations['IndexedGetter']
|
||||||
if indexedGetter:
|
if indexedGetter:
|
||||||
indexed = ("let index = get_array_index_from_id(cx, id);\n" +
|
indexed = ("let index = get_array_index_from_id(cx, id);\n" +
|
||||||
"if index.is_some() {\n" +
|
"if let Some(index) = index {\n" +
|
||||||
" let index = index.unwrap();\n" +
|
|
||||||
" let this = UnwrapProxy(proxy);\n" +
|
" let this = UnwrapProxy(proxy);\n" +
|
||||||
" let this = &*this;\n" +
|
" let this = &*this;\n" +
|
||||||
CGIndenter(CGProxyIndexedGetter(self.descriptor)).define() + "\n" +
|
CGIndenter(CGProxyIndexedGetter(self.descriptor)).define() + "\n" +
|
||||||
|
@ -4261,8 +4258,7 @@ if !expando.ptr.is_null() {
|
||||||
indexedGetter = self.descriptor.operations['IndexedGetter']
|
indexedGetter = self.descriptor.operations['IndexedGetter']
|
||||||
if indexedGetter:
|
if indexedGetter:
|
||||||
getIndexedOrExpando = ("let index = get_array_index_from_id(cx, id);\n" +
|
getIndexedOrExpando = ("let index = get_array_index_from_id(cx, id);\n" +
|
||||||
"if index.is_some() {\n" +
|
"if let Some(index) = index {\n" +
|
||||||
" let index = index.unwrap();\n" +
|
|
||||||
" let this = UnwrapProxy(proxy);\n" +
|
" let this = UnwrapProxy(proxy);\n" +
|
||||||
" let this = &*this;\n" +
|
" let this = &*this;\n" +
|
||||||
CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define())
|
CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue