calculating the action length without writing it to a stream

This commit is contained in:
2015-07-17 09:19:51 +02:00
parent 3e7d891280
commit a6dc717225
35 changed files with 454 additions and 326 deletions
@@ -16,13 +16,15 @@
*/
package com.jpexs.helpers;
import com.jpexs.decompiler.flash.SWFInputStream;
/**
*
* @author JPEXS
*/
public class ByteArrayRange {
public static final ByteArrayRange EMPTY = new ByteArrayRange(new byte[0]);
public static final ByteArrayRange EMPTY = new ByteArrayRange(SWFInputStream.BYTE_ARRAY_EMPTY);
private final byte[] array;
@@ -1,18 +1,19 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.␍ */
* License along with this library.
*/
package com.jpexs.helpers.utf8;
import java.io.UnsupportedEncodingException;
@@ -38,4 +39,9 @@ public class Utf8Helper {
public static byte[] getBytes(String string) {
return string.getBytes(charset);
}
public static int getBytesLength(String string) {
// todo: make it faster without actually writing it to an array
return string.getBytes(charset).length;
}
}