Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
542d5e85
Commit
542d5e85
authored
Oct 23, 2016
by
Guolin Ke
Committed by
GitHub
Oct 23, 2016
Browse files
clean code
parent
623ac048
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
26 deletions
+16
-26
include/LightGBM/utils/lru_pool.h
include/LightGBM/utils/lru_pool.h
+16
-26
No files found.
include/LightGBM/utils/lru_pool.h
View file @
542d5e85
...
...
@@ -25,20 +25,8 @@ public:
* \brief Destructor
*/
~
LRUPool
()
{
if
(
pool_
!=
nullptr
)
{
delete
[]
pool_
;
}
if
(
mapper_
!=
nullptr
)
{
delete
[]
mapper_
;
}
if
(
inverse_mapper_
!=
nullptr
)
{
delete
[]
inverse_mapper_
;
}
if
(
last_used_time_
!=
nullptr
)
{
delete
[]
last_used_time_
;
}
FreeAll
();
}
/*!
* \brief Reset pool size
* \param cache_size Max cache size
...
...
@@ -46,19 +34,7 @@ public:
*/
void
ResetSize
(
int
cache_size
,
int
total_size
)
{
// free old memory
if
(
pool_
!=
nullptr
)
{
delete
[]
pool_
;
}
if
(
mapper_
!=
nullptr
)
{
delete
[]
mapper_
;
}
if
(
inverse_mapper_
!=
nullptr
)
{
delete
[]
inverse_mapper_
;
}
if
(
last_used_time_
!=
nullptr
)
{
delete
[]
last_used_time_
;
}
FreeAll
();
cache_size_
=
cache_size
;
// at least need 2 bucket to store smaller leaf and larger leaf
CHECK
(
cache_size_
>=
2
);
...
...
@@ -146,6 +122,20 @@ public:
inverse_mapper_
[
slot
]
=
dst_idx
;
}
private:
void
FreeAll
(){
if
(
pool_
!=
nullptr
)
{
delete
[]
pool_
;
}
if
(
mapper_
!=
nullptr
)
{
delete
[]
mapper_
;
}
if
(
inverse_mapper_
!=
nullptr
)
{
delete
[]
inverse_mapper_
;
}
if
(
last_used_time_
!=
nullptr
)
{
delete
[]
last_used_time_
;
}
}
T
*
pool_
=
nullptr
;
int
cache_size_
;
int
total_size_
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment