[Libreoffice-commits] core.git: javaunohelper/com

rbuj robert.buj at gmail.com
Sun Aug 10 23:23:34 PDT 2014


 javaunohelper/com/sun/star/lib/uno/helper/UnoUrl.java |   15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

New commits:
commit 8d10b7373a1c77748f2119b64a3dd99f453137fe
Author: rbuj <robert.buj at gmail.com>
Date:   Mon Aug 11 03:15:20 2014 +0200

    javaunohelper: enhancements in decodeUTF8
    
    Change-Id: I452dbd54251eea683d307c346dc4949a42eedc30
    Reviewed-on: https://gerrit.libreoffice.org/10862
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

diff --git a/javaunohelper/com/sun/star/lib/uno/helper/UnoUrl.java b/javaunohelper/com/sun/star/lib/uno/helper/UnoUrl.java
index 0bae9d0..ac5f05e 100644
--- a/javaunohelper/com/sun/star/lib/uno/helper/UnoUrl.java
+++ b/javaunohelper/com/sun/star/lib/uno/helper/UnoUrl.java
@@ -18,8 +18,8 @@
 
 package com.sun.star.lib.uno.helper;
 import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
 import java.util.HashMap;
-import java.util.ArrayList;
 
 /**
  * Object representation and parsing of Uno Urls,
@@ -208,8 +208,8 @@ public class UnoUrl {
 
         try {
             if (s.contains("%")) {
-                ArrayList<Integer> v = new ArrayList<Integer>();
                 int length = s.length();
+                ByteBuffer bb = ByteBuffer.allocate(length);
                 for (int i = 0; i < length; i++) {
                     int ch = s.charAt(i);
 
@@ -228,16 +228,11 @@ public class UnoUrl {
                         i+=2;
                     }
 
-                    v.add(new Integer(ch));
-                }
-
-                int size = v.size();
-                byte[] bytes = new byte[size];
-                for (int i = 0; i < size; i++) {
-                    Integer anInt = v.get(i);
-                    bytes[i] = (byte) (anInt.intValue() & 0xFF);
+                    bb.put((byte) (ch & 0xFF));
                 }
 
+                byte[] bytes = new byte[bb.position()];
+                System.arraycopy(bb.array(), 0, bytes, 0, bytes.length);
                 return new String(bytes, "UTF-8");
 
             } else {


More information about the Libreoffice-commits mailing list