[jruby-joni] 122/223: Reuse.

Hideki Yamane henrich at moszumanska.debian.org
Mon Nov 16 11:21:58 UTC 2015


This is an automated email from the git hooks/post-receive script.

henrich pushed a commit to branch debian/sid
in repository jruby-joni.

commit 4f2930964edb84fb8d36b4687d3a1161b89911fb
Author: Marcin Mielzynski <lopx at gazeta.pl>
Date:   Sun Mar 11 20:38:58 2012 +0100

    Reuse.
---
 src/org/joni/ast/StringNode.java | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/org/joni/ast/StringNode.java b/src/org/joni/ast/StringNode.java
index d71034f..15ed04c 100644
--- a/src/org/joni/ast/StringNode.java
+++ b/src/org/joni/ast/StringNode.java
@@ -66,8 +66,8 @@ public final class StringNode extends Node implements StringType {
     /* COW and/or ensure there is ahead bytes available in node's buffer
      */
     private void modifyEnsure(int ahead) {
-        int len = (end - p) + ahead;
         if (isShared()) {
+            int len = (end - p) + ahead;
             byte[]tmp = new byte[len + NODE_STR_MARGIN];
             System.arraycopy(bytes, p, tmp, 0, end - p);
             bytes = tmp;
@@ -75,11 +75,7 @@ public final class StringNode extends Node implements StringType {
             p = 0;
             clearShared();
         } else {
-            if (len >= bytes.length) {
-                byte[]tmp = new byte[len + NODE_STR_MARGIN];
-                System.arraycopy(bytes, p, tmp, 0, end - p);
-                bytes = tmp;
-            }
+            ensure(ahead);
         }
     }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jruby-joni.git



More information about the pkg-java-commits mailing list