<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jan 6, 2017 at 7:22 AM, Rafael Avila de Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Rui Ueyama via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> writes:<br>
> +static std::string formatPax(StringRef Key, const Twine &Val) {<br>
> +  int Len = Key.size() + Val.str().size() + 3; // +3 for " ", "=" and<br>
> "\n"<br>
<br>
Nit: Save the temporary str() and you can reused them in the function.<br></blockquote><div><br></div><div>I could, but because the data this function will handle is small, I think we don't need to optimize it.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> +// Headers in tar files must be aligned to 512 byte boundaries.<br>
> +// This function writes null bytes so that the file is a multiple<br>
> +// of 512 bytes.<br>
> +static void pad(raw_ostream &OS) {<br>
> +  uint64_t Pos = OS.tell();<br>
> +  if (Pos % BlockSize == 0)<br>
> +    return;<br>
> +  OS << std::string(BlockSize - Pos % BlockSize, '\0');<br>
<br>
Nit: Don't allocate a string for this.<br></blockquote><div><br></div><div>Changed to use OS.seek().</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> +// We want to use '/' as a path separator even on Windows.<br>
> +// This function canonicalizes a given path.<br>
> +static std::string canonicalize(StringRef S) {<br>
<br>
this is lld::<wbr>convertToUnixPathSeparator.<br></blockquote><div><br></div><div>Yes, but we cannot use LLD's function from LLVM.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
This is a lot simpler than what I was expecting when I first looked at<br>
tar. I agree that while the format is ugly, it is far more common and<br>
the command line is more user friendly.<br>
<br>
Cheers,<br>
Rafael<br>
</blockquote></div><br></div></div>