mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 16:17:17 +00:00
[Object][Archive] Use uint64_t instead of APInt. It is significantly faster.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172015 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -48,9 +48,9 @@ struct ArchiveMemberHeader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint64_t getSize() const {
|
uint64_t getSize() const {
|
||||||
APInt ret;
|
uint64_t ret;
|
||||||
StringRef(Size, sizeof(Size)).getAsInteger(10, ret);
|
StringRef(Size, sizeof(Size)).getAsInteger(10, ret);
|
||||||
return ret.getZExtValue();
|
return ret;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -110,11 +110,11 @@ error_code Archive::Child::getName(StringRef &Result) const {
|
|||||||
}
|
}
|
||||||
// It's a long name.
|
// It's a long name.
|
||||||
// Get the offset.
|
// Get the offset.
|
||||||
APInt offset;
|
uint64_t offset;
|
||||||
name.substr(1).getAsInteger(10, offset);
|
name.substr(1).getAsInteger(10, offset);
|
||||||
const char *addr = Parent->StringTable->Data.begin()
|
const char *addr = Parent->StringTable->Data.begin()
|
||||||
+ sizeof(ArchiveMemberHeader)
|
+ sizeof(ArchiveMemberHeader)
|
||||||
+ offset.getZExtValue();
|
+ offset;
|
||||||
// Verify it.
|
// Verify it.
|
||||||
if (Parent->StringTable == Parent->end_children()
|
if (Parent->StringTable == Parent->end_children()
|
||||||
|| addr < (Parent->StringTable->Data.begin()
|
|| addr < (Parent->StringTable->Data.begin()
|
||||||
@@ -133,9 +133,9 @@ error_code Archive::Child::getName(StringRef &Result) const {
|
|||||||
}
|
}
|
||||||
return object_error::success;
|
return object_error::success;
|
||||||
} else if (name.startswith("#1/")) {
|
} else if (name.startswith("#1/")) {
|
||||||
APInt name_size;
|
uint64_t name_size;
|
||||||
name.substr(3).getAsInteger(10, name_size);
|
name.substr(3).getAsInteger(10, name_size);
|
||||||
Result = Data.substr(0, name_size.getZExtValue());
|
Result = Data.substr(0, name_size);
|
||||||
return object_error::success;
|
return object_error::success;
|
||||||
}
|
}
|
||||||
// It's a simple name.
|
// It's a simple name.
|
||||||
@@ -151,9 +151,9 @@ uint64_t Archive::Child::getSize() const {
|
|||||||
// Don't include attached name.
|
// Don't include attached name.
|
||||||
StringRef name = ToHeader(Data.data())->getName();
|
StringRef name = ToHeader(Data.data())->getName();
|
||||||
if (name.startswith("#1/")) {
|
if (name.startswith("#1/")) {
|
||||||
APInt name_size;
|
uint64_t name_size;
|
||||||
name.substr(3).getAsInteger(10, name_size);
|
name.substr(3).getAsInteger(10, name_size);
|
||||||
size -= name_size.getZExtValue();
|
size -= name_size;
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
@@ -163,9 +163,9 @@ MemoryBuffer *Archive::Child::getBuffer() const {
|
|||||||
if (getName(name)) return NULL;
|
if (getName(name)) return NULL;
|
||||||
int size = sizeof(ArchiveMemberHeader);
|
int size = sizeof(ArchiveMemberHeader);
|
||||||
if (name.startswith("#1/")) {
|
if (name.startswith("#1/")) {
|
||||||
APInt name_size;
|
uint64_t name_size;
|
||||||
name.substr(3).getAsInteger(10, name_size);
|
name.substr(3).getAsInteger(10, name_size);
|
||||||
size += name_size.getZExtValue();
|
size += name_size;
|
||||||
}
|
}
|
||||||
return MemoryBuffer::getMemBuffer(Data.substr(size, getSize()),
|
return MemoryBuffer::getMemBuffer(Data.substr(size, getSize()),
|
||||||
name,
|
name,
|
||||||
|
Reference in New Issue
Block a user