File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -153,7 +153,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
153
153
* @throws NoSuchElementException if no `Value` with a matching
154
154
* name is in this `Enumeration`
155
155
*/
156
- final def withName (s : String ): Value = values.find(_.toString == s). getOrElse(
156
+ final def withName (s : String ): Value = values.byName. getOrElse(s,
157
157
throw new NoSuchElementException (s " No value found for ' $s' " ))
158
158
159
159
/** Creates a fresh value, part of this enumeration. */
@@ -200,7 +200,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
200
200
val value = m.invoke(this ).asInstanceOf [Value ]
201
201
// verify that outer points to the correct Enumeration: ticket #3616.
202
202
if (value.outerEnum eq thisenum) {
203
- val id = Int .unbox( classOf [ Val ] getMethod " id " invoke value)
203
+ val id : Int = value.id
204
204
nmap += ((id, name))
205
205
}
206
206
}
@@ -294,6 +294,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
294
294
/** Creates a bit mask for the zero-adjusted ids in this set as a
295
295
* new array of longs */
296
296
def toBitMask : Array [Long ] = nnIds.toBitMask
297
+ private [Enumeration ] lazy val byName : Map [String , Value ] = iterator.map( v => v.toString -> v).toMap
297
298
}
298
299
299
300
/** A factory object for value sets */
You can’t perform that action at this time.
0 commit comments