@@ -240,64 +240,61 @@ object Names {
240
240
/** Create a term name from the characters in cs[offset..offset+len-1].
241
241
* Assume they are already encoded.
242
242
*/
243
- def termName (cs : Array [Char ], offset : Int , len : Int ): TermName = {
243
+ def termName (cs : Array [Char ], offset : Int , len : Int ): TermName = synchronized {
244
244
util.Stats .record(" termName" )
245
245
val h = hashValue(cs, offset, len) & (table.size - 1 )
246
246
247
- synchronized {
248
-
249
- /** Make sure the capacity of the character array is at least `n` */
250
- def ensureCapacity (n : Int ) =
251
- if (n > chrs.length) {
252
- val newchrs = new Array [Char ](chrs.length * 2 )
253
- chrs.copyToArray(newchrs)
254
- chrs = newchrs
255
- }
256
-
257
- /** Enter characters into chrs array. */
258
- def enterChars (): Unit = {
259
- ensureCapacity(nc + len)
260
- var i = 0
261
- while (i < len) {
262
- chrs(nc + i) = cs(offset + i)
263
- i += 1
264
- }
265
- nc += len
247
+ /** Make sure the capacity of the character array is at least `n` */
248
+ def ensureCapacity (n : Int ) =
249
+ if (n > chrs.length) {
250
+ val newchrs = new Array [Char ](chrs.length * 2 )
251
+ chrs.copyToArray(newchrs)
252
+ chrs = newchrs
266
253
}
267
254
268
- /** Rehash chain of names */
269
- def rehash (name : TermName ): Unit =
270
- if (name != null ) {
271
- val oldNext = name.next
272
- val h = hashValue(chrs, name.start, name.length) & (table.size - 1 )
273
- name.next = table(h)
274
- table(h) = name
275
- rehash(oldNext)
276
- }
255
+ /** Enter characters into chrs array. */
256
+ def enterChars (): Unit = {
257
+ ensureCapacity(nc + len)
258
+ var i = 0
259
+ while (i < len) {
260
+ chrs(nc + i) = cs(offset + i)
261
+ i += 1
262
+ }
263
+ nc += len
264
+ }
277
265
278
- /** Make sure the hash table is large enough for the given load factor */
279
- def incTableSize () = {
280
- size += 1
281
- if (size.toDouble / table.size > fillFactor) {
282
- val oldTable = table
283
- table = new Array [ TermName ]( table.size * 2 )
284
- for (i <- 0 until oldTable.size) rehash(oldTable(i))
285
- }
266
+ /** Rehash chain of names */
267
+ def rehash ( name : TermName ) : Unit =
268
+ if (name != null ) {
269
+ val oldNext = name.next
270
+ val h = hashValue(chrs, name.start, name.length) & ( table.size - 1 )
271
+ name.next = table(h )
272
+ table(h) = name
273
+ rehash(oldNext)
286
274
}
287
275
288
- val next = table(h)
289
- var name = next
290
- while (name ne null ) {
291
- if (name.length == len && equals(name.start, cs, offset, len))
292
- return name
293
- name = name.next
276
+ /** Make sure the hash table is large enough for the given load factor */
277
+ def incTableSize () = {
278
+ size += 1
279
+ if (size.toDouble / table.size > fillFactor) {
280
+ val oldTable = table
281
+ table = new Array [TermName ](table.size * 2 )
282
+ for (i <- 0 until oldTable.size) rehash(oldTable(i))
294
283
}
295
- name = new TermName (nc, len, next)
296
- enterChars()
297
- table(h) = name
298
- incTableSize()
299
- name
300
284
}
285
+
286
+ val next = table(h)
287
+ var name = next
288
+ while (name ne null ) {
289
+ if (name.length == len && equals(name.start, cs, offset, len))
290
+ return name
291
+ name = name.next
292
+ }
293
+ name = new TermName (nc, len, next)
294
+ enterChars()
295
+ table(h) = name
296
+ incTableSize()
297
+ name
301
298
}
302
299
303
300
/** Create a type name from the characters in cs[offset..offset+len-1].
0 commit comments