JDK-4191365 : java.io.DataOutputStream.writeUTF could be faster
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.2.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: x86
  • Submitted: 1998-11-19
  • Updated: 2013-11-01
  • Resolved: 1999-04-19
Related Reports
Duplicate :  
Relates :  
Description
DataOutputStream.writeUTF runs through its argument String twice using 
String.charAt.  Instead, it could use String.getChars to get the chars 
into a local char[] and then walk that (twice).  This would save two 
calls to String.charAt per char, and would avoid the explicit range 
checks that String.charAt does.  One hopes this change would allow a 
good compiler to elide the subscript range checks on the array access, 
etc. generating generally better code.

One might want to avoid the extra char[] if the argument String were 
very long, to avoid running out of memory.

peter.kessler@Eng 1998-11-19

Comments
EVALUATION Do it. -- mr@eng 1998/11/24
11-06-0190