Skip to content

Commit 134faef

Browse files
committed
Remove unused serialization-related code
`LinkedHashMap/Set` extend `DefaultSerializable`, so instances are not directly serialized, the `DefaultSerializationProxy` is used instead. Serialization-related code in `LinkedHashMap/Set` is unused.
1 parent 5f065ed commit 134faef

File tree

2 files changed

+6
-75
lines changed

2 files changed

+6
-75
lines changed

library/src/scala/collection/mutable/LinkedHashMap.scala

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ class LinkedHashMap[K, V]
5050

5151
private[collection] def _firstEntry: Entry = firstEntry
5252

53-
@transient protected var firstEntry: Entry = null
53+
protected var firstEntry: Entry = null
5454

55-
@transient protected var lastEntry: Entry = null
55+
protected var lastEntry: Entry = null
5656

5757
/* Uses the same implementation as mutable.HashMap. The hashtable holds the following invariant:
5858
* - For each i between 0 and table.length, the bucket at table(i) only contains keys whose hash-index is i.
5959
* - Every bucket is sorted in ascendant hash order
6060
* - The sum of the lengths of all buckets is equal to contentSize.
6161
*/
62-
@transient private[this] var table = new Array[Entry](tableSizeFor(LinkedHashMap.defaultinitialSize))
62+
private[this] var table = new Array[Entry](tableSizeFor(LinkedHashMap.defaultinitialSize))
6363

6464
private[this] var threshold: Int = newThreshold(table.length)
6565

@@ -394,42 +394,6 @@ class LinkedHashMap[K, V]
394394
}
395395
}
396396

397-
private[this] def serializeTo(out: java.io.ObjectOutputStream, writeEntry: Entry => Unit): Unit = {
398-
out.writeInt(contentSize)
399-
var cur = firstEntry
400-
while (cur ne null) {
401-
writeEntry(cur)
402-
cur = cur.later
403-
}
404-
}
405-
406-
private def writeObject(out: java.io.ObjectOutputStream): Unit = {
407-
out.defaultWriteObject()
408-
serializeTo(out, { entry =>
409-
out.writeObject(entry.key)
410-
out.writeObject(entry.value)
411-
})
412-
}
413-
414-
private[this] def serializeFrom(in: java.io.ObjectInputStream, readEntry: => (K, V)): Unit = {
415-
val _contentsize = in.readInt()
416-
assert(_contentsize > 0)
417-
clear()
418-
table = new Array(tableSizeFor(_contentsize))
419-
threshold = newThreshold(table.length)
420-
421-
var index = 0
422-
while (index < size) {
423-
addOne(readEntry)
424-
index += 1
425-
}
426-
}
427-
428-
private def readObject(in: java.io.ObjectInputStream): Unit = {
429-
in.defaultReadObject()
430-
serializeFrom(in, (in.readObject().asInstanceOf[K], in.readObject().asInstanceOf[V]))
431-
}
432-
433397
@nowarn("""cat=deprecation&origin=scala\.collection\.Iterable\.stringPrefix""")
434398
override protected[this] def stringPrefix = "LinkedHashMap"
435399
}

library/src/scala/collection/mutable/LinkedHashSet.scala

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ class LinkedHashSet[A]
4444

4545
type Entry = LinkedHashSet.Entry[A]
4646

47-
@transient protected var firstEntry: Entry = null
47+
protected var firstEntry: Entry = null
4848

49-
@transient protected var lastEntry: Entry = null
49+
protected var lastEntry: Entry = null
5050

5151
/* Uses the same implementation as mutable.HashSet. The hashtable holds the following invariant:
5252
* - For each i between 0 and table.length, the bucket at table(i) only contains keys whose hash-index is i.
5353
* - Every bucket is sorted in ascendant hash order
5454
* - The sum of the lengths of all buckets is equal to contentSize.
5555
*/
56-
@transient private[this] var table = new Array[Entry](tableSizeFor(LinkedHashSet.defaultinitialSize))
56+
private[this] var table = new Array[Entry](tableSizeFor(LinkedHashSet.defaultinitialSize))
5757

5858
private[this] var threshold: Int = newThreshold(table.length)
5959

@@ -270,39 +270,6 @@ class LinkedHashSet[A]
270270
}
271271
}
272272

273-
private[this] def serializeTo(out: java.io.ObjectOutputStream, writeEntry: Entry => Unit): Unit = {
274-
out.writeInt(contentSize)
275-
var cur = firstEntry
276-
while (cur ne null) {
277-
writeEntry(cur)
278-
cur = cur.later
279-
}
280-
}
281-
282-
private def writeObject(out: java.io.ObjectOutputStream): Unit = {
283-
out.defaultWriteObject()
284-
serializeTo(out, { e => out.writeObject(e.key) })
285-
}
286-
287-
private[this] def serializeFrom(in: java.io.ObjectInputStream, readEntry: => A): Unit = {
288-
val _contentsize = in.readInt()
289-
assert(_contentsize > 0)
290-
clear()
291-
table = new Array(tableSizeFor(_contentsize))
292-
threshold = newThreshold(table.length)
293-
294-
var index = 0
295-
while (index < size) {
296-
addOne(readEntry)
297-
index += 1
298-
}
299-
}
300-
301-
private def readObject(in: java.io.ObjectInputStream): Unit = {
302-
in.defaultReadObject()
303-
serializeFrom(in, in.readObject().asInstanceOf[A])
304-
}
305-
306273
@nowarn("""cat=deprecation&origin=scala\.collection\.Iterable\.stringPrefix""")
307274
override protected[this] def stringPrefix = "LinkedHashSet"
308275
}

0 commit comments

Comments
 (0)