mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 23:32:27 +00:00
eliminate an extraneous use of SmallVector in a case where
a fixed size buffer is perfectly fine. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91527 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
99ea87a48a
commit
e4b0cd2856
@ -414,21 +414,19 @@ Path::getSuffix() const {
|
|||||||
return path.substr(dot + 1);
|
return path.substr(dot + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Path::getMagicNumber(std::string& Magic, unsigned len) const {
|
bool Path::getMagicNumber(std::string &Magic, unsigned len) const {
|
||||||
assert(len < 1024 && "Request for magic string too long");
|
assert(len < 1024 && "Request for magic string too long");
|
||||||
SmallVector<char, 128> Buf;
|
char Buf[1025];
|
||||||
Buf.resize(1 + len);
|
|
||||||
char* buf = Buf.data();
|
|
||||||
int fd = ::open(path.c_str(), O_RDONLY);
|
int fd = ::open(path.c_str(), O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return false;
|
return false;
|
||||||
ssize_t bytes_read = ::read(fd, buf, len);
|
ssize_t bytes_read = ::read(fd, Buf, len);
|
||||||
::close(fd);
|
::close(fd);
|
||||||
if (ssize_t(len) != bytes_read) {
|
if (ssize_t(len) != bytes_read) {
|
||||||
Magic.clear();
|
Magic.clear();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Magic.assign(buf,len);
|
Magic.assign(Buf, len);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user