diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h
index 269d16af618..b07dcc12ced 100644
--- a/include/llvm/ADT/StringRef.h
+++ b/include/llvm/ADT/StringRef.h
@@ -46,7 +46,7 @@ namespace llvm {
 
     /// Construct a string ref from a cstring.
     /*implicit*/ StringRef(const char *Str)
-      : Data(Str) { if (Str) Length = ::strlen(Str); else Length = 0; }
+      : Data(Str), Length(::strlen(Str)) {}
 
     /// Construct a string ref from a pointer and length.
     /*implicit*/ StringRef(const char *data, size_t length)