mirror of
https://github.com/status-im/react-native.git
synced 2025-01-28 18:25:06 +00:00
Shortcut JSBigFileString in when no offset is used
Reviewed By: mhorowitz Differential Revision: D5227225 fbshipit-source-id: a50688c8b873bf08ea10fafaa143df130f59dfaa
This commit is contained in:
parent
eb6ba0b041
commit
8497ec297c
@ -112,20 +112,25 @@ public:
|
|||||||
: m_fd {-1}
|
: m_fd {-1}
|
||||||
, m_data {nullptr}
|
, m_data {nullptr}
|
||||||
{
|
{
|
||||||
folly::checkUnixError(
|
folly::checkUnixError(m_fd = dup(fd),
|
||||||
m_fd = dup(fd),
|
"Could not duplicate file descriptor");
|
||||||
"Could not duplicate file descriptor");
|
|
||||||
|
|
||||||
// Offsets given to mmap must be page aligend. We abstract away that
|
// Offsets given to mmap must be page aligend. We abstract away that
|
||||||
// restriction by sending a page aligned offset to mmap, and keeping track
|
// restriction by sending a page aligned offset to mmap, and keeping track
|
||||||
// of the offset within the page that we must alter the mmap pointer by to
|
// of the offset within the page that we must alter the mmap pointer by to
|
||||||
// get the final desired offset.
|
// get the final desired offset.
|
||||||
auto ps = getpagesize();
|
if (offset != 0) {
|
||||||
auto d = lldiv(offset, ps);
|
const static auto ps = getpagesize();
|
||||||
|
auto d = lldiv(offset, ps);
|
||||||
|
|
||||||
m_mapOff = d.quot;
|
m_mapOff = d.quot;
|
||||||
m_pageOff = d.rem;
|
m_pageOff = d.rem;
|
||||||
m_size = size + m_pageOff;
|
m_size = size + m_pageOff;
|
||||||
|
} else {
|
||||||
|
m_mapOff = 0;
|
||||||
|
m_pageOff = 0;
|
||||||
|
m_size = size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~JSBigFileString() {
|
~JSBigFileString() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user