mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +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,
|
||||
'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" +
|
||||
|
@ -4102,8 +4101,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() +
|
||||
|
@ -4186,8 +4184,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" +
|
||||
|
@ -4259,8 +4256,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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue