diff options
author | Chris Lattner <sabre@nondot.org> | 2009-12-16 08:35:54 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-12-16 08:35:54 +0000 |
commit | e6be85661d1d29d7b283edbb3b57b60d0c92827e (patch) | |
tree | cc65376c19894a8efb5fab5d8f6592f40f6e4e9a /llvm/lib/System/Unix | |
parent | 5c0917c175bbf369fc4b2fdf1185544d94079c1a (diff) | |
download | bcm5719-llvm-e6be85661d1d29d7b283edbb3b57b60d0c92827e.tar.gz bcm5719-llvm-e6be85661d1d29d7b283edbb3b57b60d0c92827e.zip |
eliminate an extraneous use of SmallVector in a case where
a fixed size buffer is perfectly fine.
llvm-svn: 91527
Diffstat (limited to 'llvm/lib/System/Unix')
-rw-r--r-- | llvm/lib/System/Unix/Path.inc | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/llvm/lib/System/Unix/Path.inc b/llvm/lib/System/Unix/Path.inc index 33b26f7e842..b544bd8ec3c 100644 --- a/llvm/lib/System/Unix/Path.inc +++ b/llvm/lib/System/Unix/Path.inc @@ -414,21 +414,19 @@ Path::getSuffix() const { 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"); - SmallVector<char, 128> Buf; - Buf.resize(1 + len); - char* buf = Buf.data(); + char Buf[1025]; int fd = ::open(path.c_str(), O_RDONLY); if (fd < 0) return false; - ssize_t bytes_read = ::read(fd, buf, len); + ssize_t bytes_read = ::read(fd, Buf, len); ::close(fd); if (ssize_t(len) != bytes_read) { Magic.clear(); return false; } - Magic.assign(buf,len); + Magic.assign(Buf, len); return true; } |