[llvm-commits] [llvm] r91527 - /llvm/trunk/lib/System/Unix/Path.inc

Chris Lattner sabre at nondot.org
Wed Dec 16 00:35:55 PST 2009


Author: lattner
Date: Wed Dec 16 02:35:54 2009
New Revision: 91527

URL: http://llvm.org/viewvc/llvm-project?rev=91527&view=rev
Log:
eliminate an extraneous use of SmallVector in a case where
a fixed size buffer is perfectly fine.

Modified:
    llvm/trunk/lib/System/Unix/Path.inc

Modified: llvm/trunk/lib/System/Unix/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Path.inc?rev=91527&r1=91526&r2=91527&view=diff

==============================================================================
--- llvm/trunk/lib/System/Unix/Path.inc (original)
+++ llvm/trunk/lib/System/Unix/Path.inc Wed Dec 16 02:35:54 2009
@@ -414,21 +414,19 @@
     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;
 }
 





More information about the llvm-commits mailing list