mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Prefer if..let over if..is_some..unwrap in codegen
This commit is contained in:
parent
f3b7c5cb4b
commit
7a774a198c
1 changed files with 4 additions and 8 deletions
|
@ -4032,8 +4032,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" +
|
||||||
|
@ -4102,8 +4101,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() +
|
||||||
|
@ -4186,8 +4184,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" +
|
||||||
|
@ -4259,8 +4256,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