This is an archive of the discontinued LLVM Phabricator instance.

[Support] Replace function with function_ref in writeFileAtomically. NFC
AbandonedPublic

Authored by ilya-biryukov on Sep 14 2019, 1:28 AM.

Details

Summary

The latter is slightly more efficient and communicates the intent of the
API: writeFileAtomically does not own or copy the callback, it merely
calls it at some point.

Diff Detail

Repository
rL LLVM

Event Timeline

ilya-biryukov created this revision.Sep 14 2019, 1:28 AM
jkorous accepted this revision.Sep 17 2019, 10:39 AM

Good point! Thanks.

This revision is now accepted and ready to land.Sep 17 2019, 10:39 AM
This revision was automatically updated to reflect the committed changes.
ilya-biryukov reopened this revision.Sep 18 2019, 1:49 AM

Ah, the tests fail to compile because we now have an overload where the only difference is function_ref vs StringRef.
This works fine with std::function, STL probably ensures the conversions from StringRef to std::functtion fail and function_ref will only fail at constructor instantiation time.

I'll keep this open for now, will see if it's feasible to make function_ref similar to std::function in that case.

This revision is now accepted and ready to land.Sep 18 2019, 1:49 AM
ilya-biryukov abandoned this revision.Nov 21 2019, 3:01 AM