From a2977e635165b56f41566bd30e71f6fe0d928357 Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Wed, 22 Aug 2018 18:33:28 +0000 Subject: [PATCH] Refactored a Java method to reduce indirection. --- java/io/nayuki/qrcodegen/BitBuffer.java | 11 +++++------ java/io/nayuki/qrcodegen/QrCode.java | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/java/io/nayuki/qrcodegen/BitBuffer.java b/java/io/nayuki/qrcodegen/BitBuffer.java index 861ffcc..b596566 100644 --- a/java/io/nayuki/qrcodegen/BitBuffer.java +++ b/java/io/nayuki/qrcodegen/BitBuffer.java @@ -110,15 +110,14 @@ public final class BitBuffer implements Cloneable { /** - * Appends the bit data of the specified segment to this bit buffer. - * @param seg the segment whose data to append (not {@code null}) - * @throws NullPointerException if the segment is {@code null} + * Appends the specified bit buffer to this bit buffer. + * @param bb the bit buffer whose data to append (not {@code null}) + * @throws NullPointerException if the bit buffer is {@code null} * @throws IllegalStateException if appending the data * would make bitLength exceed Integer.MAX_VALUE */ - public void appendData(QrSegment seg) { - Objects.requireNonNull(seg); - BitBuffer bb = seg.data; + public void appendData(BitBuffer bb) { + Objects.requireNonNull(bb); if (Integer.MAX_VALUE - bitLength < bb.bitLength) throw new IllegalStateException("Maximum length reached"); for (int i = 0; i < bb.bitLength; i++, bitLength++) // Append bit by bit diff --git a/java/io/nayuki/qrcodegen/QrCode.java b/java/io/nayuki/qrcodegen/QrCode.java index b56c55d..ed83219 100644 --- a/java/io/nayuki/qrcodegen/QrCode.java +++ b/java/io/nayuki/qrcodegen/QrCode.java @@ -142,7 +142,7 @@ public final class QrCode { for (QrSegment seg : segs) { bb.appendBits(seg.mode.modeBits, 4); bb.appendBits(seg.numChars, seg.mode.numCharCountBits(version)); - bb.appendData(seg); + bb.appendData(seg.data); } // Add terminator and pad up to a byte if applicable