On 04/17/22 11:04, Richard W.M. Jones wrote:
On Sun, Apr 17, 2022 at 09:13:55AM +0200, Laszlo Ersek wrote:
> Another style point / simplification has occurred to me the other day
> too: in the patch I use the following expression four times:
>
> ([ device_model ] @ common_props)
>
> that should be just
>
> (device_model :: common_props)
The second one is more efficient too. I just checked and ocamlopt
4.13.1 can't optimise the first one at all, there's still an explicit
call to camlStdlib__$40 (@). The second one just allocates a cons
cell inline.
Rich.
Merged as commit 8643970f9791 (after retesting), with the following diff
squashed:
diff --git a/output/output_qemu.ml b/output/output_qemu.ml
index da8bd475e56e..f5e43705d101 100644
--- a/output/output_qemu.ml
+++ b/output/output_qemu.ml
@@ -197,7 +197,8 @@ module QEMU = struct
and floppy_filter =
function
| BusSlotRemovable { s_removable_type = Floppy } -> true
- | _ -> false in
+ | _ -> false
+ in
let ide_ctrl_needed =
Array.exists disk_cdrom_filter target_buses.target_ide_bus
and scsi_ctrl_needed =
@@ -261,7 +262,8 @@ module QEMU = struct
and add_floppy_backend backend_name =
(* Add a drive (back-end) for a "floppy" device (front-end). The drive
is
* empty -- there is no backing file. *)
- arg_list "-drive" [ "if=none"; "id=" ^ backend_name;
"media=disk" ] in
+ arg_list "-drive" [ "if=none"; "id=" ^ backend_name;
"media=disk" ]
+ in
let add_virtio_blk disk_id frontend_ctr =
(* Create a "virtio-blk-pci" device (front-end), together with its drive
@@ -289,10 +291,10 @@ module QEMU = struct
(match disk_id with
| Some id ->
add_disk_backend id backend_name;
- arg_list "-device" ([ "ide-hd" ] @ common_props)
+ arg_list "-device" ("ide-hd" :: common_props)
| None ->
add_cdrom_backend backend_name;
- arg_list "-device" ([ "ide-cd" ] @ common_props))
+ arg_list "-device" ("ide-cd" :: common_props))
and add_scsi disk_id frontend_ctr =
(* Create a "scsi-hd" or "scsi-cd" device (front-end), together
with its
@@ -307,10 +309,10 @@ module QEMU = struct
(match disk_id with
| Some id ->
add_disk_backend id backend_name;
- arg_list "-device" ([ "scsi-hd" ] @ common_props)
+ arg_list "-device" ("scsi-hd" :: common_props)
| None ->
add_cdrom_backend backend_name;
- arg_list "-device" ([ "scsi-cd" ] @ common_props))
+ arg_list "-device" ("scsi-cd" :: common_props))
and add_floppy frontend_ctr =
(* Create a "floppy" (front-end), together with its empty drive
@@ -320,7 +322,8 @@ module QEMU = struct
add_floppy_backend backend_name;
arg_list "-device" [ "floppy"; "bus=floppy-bus.0";
sprintf "unit=%d" frontend_ctr;
- "drive=" ^ backend_name ] in
+ "drive=" ^ backend_name ]
+ in
(* Add virtio-blk-pci devices for BusSlotDisk elements on
* "target_virtio_blk_bus".
@@ -339,7 +342,8 @@ module QEMU = struct
bus_adder (Some d.s_disk_id) frontend_ctr
| BusSlotRemovable { s_removable_type = CDROM } ->
bus_adder None frontend_ctr
- | _ -> () in
+ | _ -> ()
+ in
(* Add disks and CD-ROMs to the IDE and SCSI buses. *)
Array.iteri (add_disk_or_cdrom add_ide) target_buses.target_ide_bus;
Thanks
Laszlo