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 | e4b0cd2856063933fbadd17e68b2cb638c30000c (patch) | |
tree | 1d5366d992778716767835d6c47d3994b56e86c9 /lib/System | |
parent | 99ea87a48a3a891dbf5f4cb89179610a5f3f84cf (diff) | |
download | external_llvm-e4b0cd2856063933fbadd17e68b2cb638c30000c.zip external_llvm-e4b0cd2856063933fbadd17e68b2cb638c30000c.tar.gz external_llvm-e4b0cd2856063933fbadd17e68b2cb638c30000c.tar.bz2 |
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
Diffstat (limited to 'lib/System')
-rw-r--r-- | lib/System/Unix/Path.inc | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc index 33b26f7..b544bd8 100644 --- a/lib/System/Unix/Path.inc +++ b/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; } |