1414package com .google .devtools .build .lib .actions .cache ;
1515
1616import static java .lang .Math .max ;
17- import static java .nio .charset .StandardCharsets .UTF_8 ;
1817
1918import com .google .devtools .build .lib .clock .Clock ;
2019import com .google .devtools .build .lib .concurrent .ThreadSafety .ConditionallyThreadSafe ;
20+ import com .google .devtools .build .lib .unsafe .StringUnsafe ;
2121import com .google .devtools .build .lib .util .MapCodec ;
2222import com .google .devtools .build .lib .util .PersistentMap ;
2323import com .google .devtools .build .lib .util .StringIndexer ;
@@ -183,7 +183,7 @@ public void dump(PrintStream out) {
183183 }
184184
185185 private static final MapCodec <String , Integer > CODEC =
186- new MapCodec <String , Integer >() {
186+ new MapCodec <>() {
187187 @ Override
188188 protected String readKey (DataInput in ) throws IOException {
189189 int length = in .readInt ();
@@ -192,7 +192,7 @@ protected String readKey(DataInput in) throws IOException {
192192 }
193193 byte [] content = new byte [length ];
194194 in .readFully (content );
195- return new String (content , UTF_8 );
195+ return StringUnsafe . newInstance (content , StringUnsafe . LATIN1 );
196196 }
197197
198198 @ Override
@@ -202,7 +202,7 @@ protected Integer readValue(DataInput in) throws IOException {
202202
203203 @ Override
204204 protected void writeKey (String key , DataOutput out ) throws IOException {
205- byte [] content = key . getBytes ( UTF_8 );
205+ byte [] content = StringUnsafe . getInternalStringBytes ( key );
206206 out .writeInt (content .length );
207207 out .write (content );
208208 }
@@ -218,7 +218,7 @@ protected void writeValue(Integer value, DataOutput out) throws IOException {
218218 * metadata cache.
219219 */
220220 private static final class PersistentIndexMap extends PersistentMap <String , Integer > {
221- private static final int VERSION = 0x01 ;
221+ private static final int VERSION = 0x02 ;
222222 private static final long SAVE_INTERVAL_NS = 3L * 1000 * 1000 * 1000 ;
223223
224224 private final Clock clock ;
0 commit comments