зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1682734 - Use a match statment to check matching instead of ifs. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D99859
This commit is contained in:
Родитель
e1b4ab410a
Коммит
4a8d704237
|
@ -1159,19 +1159,21 @@ pub fn transform_create(
|
|||
mut intent: qcms_intent,
|
||||
) -> Option<Box<qcms_transform>> {
|
||||
// Ensure the requested input and output types make sense.
|
||||
let mut match_0: bool = false;
|
||||
if in_type == DATA_RGB_8 {
|
||||
match_0 = out_type == DATA_RGB_8
|
||||
} else if in_type == DATA_RGBA_8 {
|
||||
match_0 = out_type == DATA_RGBA_8
|
||||
} else if in_type == DATA_BGRA_8 {
|
||||
match_0 = out_type == DATA_BGRA_8
|
||||
} else if in_type == DATA_GRAY_8 {
|
||||
match_0 = out_type == DATA_RGB_8 || out_type == DATA_RGBA_8 || out_type == DATA_BGRA_8
|
||||
} else if in_type == DATA_GRAYA_8 {
|
||||
match_0 = out_type == DATA_RGBA_8 || out_type == DATA_BGRA_8
|
||||
}
|
||||
if !match_0 {
|
||||
let matching_format = match (in_type, out_type) {
|
||||
(DATA_RGB_8, DATA_RGB_8) => true,
|
||||
(DATA_RGBA_8, DATA_RGBA_8) => true,
|
||||
(DATA_BGRA_8, DATA_BGRA_8) => true,
|
||||
(DATA_GRAY_8, out_type) => match out_type {
|
||||
DATA_RGB_8 | DATA_RGBA_8 | DATA_BGRA_8 => true,
|
||||
_ => false,
|
||||
},
|
||||
(DATA_GRAYA_8, out_type) => match out_type {
|
||||
DATA_RGBA_8 | DATA_BGRA_8 => true,
|
||||
_ => false,
|
||||
},
|
||||
_ => false,
|
||||
};
|
||||
if !matching_format {
|
||||
debug_assert!(false, "input/output type");
|
||||
return None;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче