-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-16911 Save some memory in CallbackRegistryImpl
- Loading branch information
Showing
4 changed files
with
79 additions
and
18 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
hibernate-core/src/main/java/org/hibernate/internal/util/collections/EmptyReadOnlyMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html | ||
*/ | ||
package org.hibernate.internal.util.collections; | ||
|
||
final class EmptyReadOnlyMap<K,V> implements ReadOnlyMap<K,V> { | ||
|
||
@Override | ||
public V get(K key) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void dispose() { | ||
//no-op | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
hibernate-core/src/main/java/org/hibernate/internal/util/collections/ReadOnlyMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html | ||
*/ | ||
package org.hibernate.internal.util.collections; | ||
|
||
public interface ReadOnlyMap<K, V> { | ||
|
||
//To help saving memory | ||
public static final ReadOnlyMap EMPTY = new EmptyReadOnlyMap(); | ||
|
||
/** | ||
* The main operation. | ||
* @param key | ||
* @return the corresponding object, or null if there is no association with any entry. | ||
*/ | ||
V get(K key); | ||
|
||
/** | ||
* Some implementations might hold on to references, | ||
* which could be just heavy or potentially harmful, | ||
* such as ClassLoader leaks: allow for proper cleanup. | ||
*/ | ||
void dispose(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters