Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e54e02fd
authored
Dec 23, 2021
by
aquilescanta
Committed by
tonihei
Jan 04, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Pre-allocate availableAllocations to prevent a re-size in release
PiperOrigin-RevId: 418022431
parent
8b119027
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultAllocator.java
library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultAllocator.java
View file @
e54e02fd
...
@@ -102,6 +102,12 @@ public final class DefaultAllocator implements Allocator {
...
@@ -102,6 +102,12 @@ public final class DefaultAllocator implements Allocator {
availableAllocations
[
availableCount
]
=
null
;
availableAllocations
[
availableCount
]
=
null
;
}
else
{
}
else
{
allocation
=
new
Allocation
(
new
byte
[
individualAllocationSize
],
0
);
allocation
=
new
Allocation
(
new
byte
[
individualAllocationSize
],
0
);
if
(
allocatedCount
>
availableAllocations
.
length
)
{
// Make availableAllocations be large enough to contain all allocations made by this
// allocator so that release() does not need to grow the availableAllocations array. See
// [Internal ref: b/209801945].
availableAllocations
=
Arrays
.
copyOf
(
availableAllocations
,
availableAllocations
.
length
*
2
);
}
}
}
return
allocation
;
return
allocation
;
}
}
...
@@ -114,12 +120,6 @@ public final class DefaultAllocator implements Allocator {
...
@@ -114,12 +120,6 @@ public final class DefaultAllocator implements Allocator {
@Override
@Override
public
synchronized
void
release
(
Allocation
[]
allocations
)
{
public
synchronized
void
release
(
Allocation
[]
allocations
)
{
if
(
availableCount
+
allocations
.
length
>=
availableAllocations
.
length
)
{
availableAllocations
=
Arrays
.
copyOf
(
availableAllocations
,
max
(
availableAllocations
.
length
*
2
,
availableCount
+
allocations
.
length
));
}
for
(
Allocation
allocation
:
allocations
)
{
for
(
Allocation
allocation
:
allocations
)
{
availableAllocations
[
availableCount
++]
=
allocation
;
availableAllocations
[
availableCount
++]
=
allocation
;
}
}
...
...
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