From c20aef323dd829b0f5fe1e204bcaed067163fc84 Mon Sep 17 00:00:00 2001 From: Rhinemann Date: Tue, 27 Jun 2023 17:49:03 +0300 Subject: [PATCH] Rewrote align_registers to accept any number of registers. --- bitutilities.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/bitutilities.py b/bitutilities.py index fdcfeb6..c62c538 100644 --- a/bitutilities.py +++ b/bitutilities.py @@ -115,9 +115,14 @@ def align_registers(first_register: BasicRegister, second_register: BasicRegiste first_size = len(first_register) second_size = len(second_register) - required_size = max(first_size, second_size) +def align_registers(*args: BasicRegister) -> tuple[BasicRegister, ...]: + """ + Aligns registers by the length of the bigger one. - if first_size != second_size: - return first_register.adjusted_by_size(required_size), second_register.adjusted_by_size(required_size) - else: - return first_register, second_register + :param args: Basic registers to align. + + :return: Aligned registers. + :rtype: tuple[BasicRegister, ...] + """ + required_size: int = max(map(len, args)) + return tuple(reg.adjusted_by_size(required_size) for reg in args)