Skip to content
This repository was archived by the owner on Aug 17, 2018. It is now read-only.

Commit 9645cde

Browse files
author
Kin Man Chung
committed
Port performance improvements on getBytes from Tomcat
svn path=/trunk/; revision=1413
1 parent 0519f8d commit 9645cde

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

impl/src/main/java/org/apache/jasper/compiler/PageDataImpl.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 1997-2011 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -61,7 +61,7 @@
6161
import java.io.InputStream;
6262
import java.io.ByteArrayInputStream;
6363
import java.io.CharArrayWriter;
64-
import java.io.UnsupportedEncodingException;
64+
import java.nio.charset.Charset;
6565
import java.util.ListIterator;
6666
import javax.servlet.jsp.tagext.PageData;
6767
import org.xml.sax.Attributes;
@@ -93,6 +93,7 @@ class PageDataImpl extends PageData implements TagConstants {
9393
private static final String JSP_VERSION = "2.0";
9494
private static final String CDATA_START_SECTION = "<![CDATA[\n";
9595
private static final String CDATA_END_SECTION = "]]>\n";
96+
private static final Charset CHARSET_UTF8 = Charset.forName("UTF-8");
9697

9798
// string buffer used to build XML view
9899
private StringBuilder buf;
@@ -127,12 +128,7 @@ public PageDataImpl(Node.Nodes page, Compiler compiler)
127128
*/
128129
public InputStream getInputStream() {
129130
// Turn StringBuilder into InputStream
130-
try {
131-
return new ByteArrayInputStream(buf.toString().getBytes("UTF-8"));
132-
} catch (UnsupportedEncodingException uee) {
133-
// should never happen
134-
throw new RuntimeException(uee.toString());
135-
}
131+
return new ByteArrayInputStream(buf.toString().getBytes(CHARSET_UTF8));
136132
}
137133

138134
/*

impl/src/main/java/org/apache/jasper/compiler/SmapUtil.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 1997-2011 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -66,6 +66,7 @@
6666
import java.io.OutputStreamWriter;
6767
import java.io.PrintWriter;
6868
import java.io.UnsupportedEncodingException;
69+
import java.nio.charset.Charset;
6970
import java.util.ArrayList;
7071
import java.util.List;
7172

@@ -160,11 +161,11 @@ public void installSmap() throws IOException {
160161
byte[] classfile = ctxt.getRuntimeContext().getBytecode(className);
161162
if (classfile == null) {
162163
SDEInstaller.install(new File(ci.getClassFileName()),
163-
ci.getSmap().getBytes());
164+
ci.getSmap().getBytes(Charset.defaultCharset()));
164165
}
165166
else {
166167
classfile = SDEInstaller.install(classfile,
167-
ci.getSmap().getBytes());
168+
ci.getSmap().getBytes(Charset.defaultCharset()));
168169
ctxt.getRuntimeContext().setBytecode(className, classfile);
169170
}
170171
}

0 commit comments

Comments
 (0)