Skip to content

Commit 37f3e2f

Browse files
author
Charisee
committed
rewriting match on endianness
1 parent 1fc0442 commit 37f3e2f

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

compiler/rustc_codegen_ssa/src/back/metadata.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,6 @@ fn add_gnu_property_note(
123123
Endianness::Big => v.to_be_bytes(),
124124
})
125125
});
126-
/*
127-
match endianness {
128-
Endianness::Little => header_values.map(|v| data.extend_from_slice(&(v.to_le_bytes()))),
129-
Endianness::Big => header_values.map(|v| data.extend_from_slice(&(v.to_be_bytes()))),
130-
};*/
131126
data.extend_from_slice(b"GNU\0"); // Owner of the program property note
132127
let pr_type: u32 = match architecture {
133128
Architecture::X86_64 => 0xc0000002,
@@ -138,10 +133,12 @@ fn add_gnu_property_note(
138133
let pr_data: u32 = 3; //program property descriptor
139134
let pr_padding: u32 = 0;
140135
let property_values = [pr_type, pr_datasz, pr_data, pr_padding];
141-
match endianness {
142-
Endianness::Little => property_values.map(|v| data.extend_from_slice(&(v.to_le_bytes()))),
143-
Endianness::Big => property_values.map(|v| data.extend_from_slice(&(v.to_be_bytes()))),
144-
};
136+
property_values.iter().for_each(|v| {
137+
data.extend_from_slice(&match endianness {
138+
Endianness::Little => v.to_le_bytes(),
139+
Endianness::Big => v.to_be_bytes(),
140+
})
141+
});
145142
file.append_section_data(section, &data, 8);
146143
}
147144

0 commit comments

Comments
 (0)