[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: rm feature: don't attempt to remove the same file twice
From: |
Ed Avis |
Subject: |
RE: rm feature: don't attempt to remove the same file twice |
Date: |
Thu, 1 Sep 2016 15:19:46 +0000 |
Adam Brenner asked:
>if I do rm -rf * in a directory with
>thousands of file, folders, links, sockets, etc. should rm keep all
>the names in memory?
The argument list already has to fit into memory - so the extra memory usage
would be keeping another copy of it in a sorted array for fast lookup.
(Given that the argument list is fixed, a more elaborate data structure which
is optimized for inserting or removing elements is probably not needed.)
Or if you want to avoid memory allocation altogether, just use the existing
in-memory copy of the argument list and linear search.
The checking of whether a file has been seen before, since it is only a
nice-to-have, could be skipped if the argument list is long (>1000).
--
Ed Avis <address@hidden>
This email is intended only for the person to whom it is addressed and may
contain confidential information. Any retransmission, copying, disclosure or
other use of, this information by persons other than the intended recipient is
prohibited. If you received this email in error, please contact the sender and
delete the material. This email is for information only and is not intended as
an offer or solicitation for the purchase or sale of any financial instrument.
Wadhwani Asset Management LLP is a Limited Liability Partnership registered in
England (OC303168) with registered office at 9th Floor Orion House, 5 Upper St
Martin’s Lane, London, WC2H 9EA. It is authorised and regulated by the
Financial Conduct Authority.