Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 15710:f63e40047372
icasefs: avoid path-absoluteness/existance check in util.fspath() for efficiency
'dirstate._normalize()', the only caller of 'util.fspath()', has
already confirmed exsistance of specified file as relative to root.
so, this patch omits path-absoluteness/existance check from
'util.fspath()'.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 16 Dec 2011 21:09:40 +0900 |
parents | a1f4bd47d18e |
children | c604a3d1969d |
comparison
equal
deleted
inserted
replaced
15709:a1f4bd47d18e | 15710:f63e40047372 |
---|---|
612 | 612 |
613 _fspathcache = {} | 613 _fspathcache = {} |
614 def fspath(name, root): | 614 def fspath(name, root): |
615 '''Get name in the case stored in the filesystem | 615 '''Get name in the case stored in the filesystem |
616 | 616 |
617 The name is either relative to root, or it is an absolute path starting | 617 The name should be relative to root, and be normcase-ed for efficiency. |
618 with root. Note that this function is unnecessary, and should not be | 618 |
619 Note that this function is unnecessary, and should not be | |
619 called, for case-sensitive filesystems (simply because it's expensive). | 620 called, for case-sensitive filesystems (simply because it's expensive). |
620 | 621 |
621 Both name and root should be normcase-ed. | 622 The root should be normcase-ed, too. |
622 ''' | 623 ''' |
623 # If name is absolute, make it relative | |
624 if name.startswith(root): | |
625 l = len(root) | |
626 if name[l] == os.sep or name[l] == os.altsep: | |
627 l = l + 1 | |
628 name = name[l:] | |
629 | |
630 if not os.path.lexists(os.path.join(root, name)): | |
631 return None | |
632 | |
633 def find(p, contents): | 624 def find(p, contents): |
634 lenp = len(p) | 625 lenp = len(p) |
635 for n in contents: | 626 for n in contents: |
636 if lenp == len(n) and normcase(n) == p: | 627 if lenp == len(n) and normcase(n) == p: |
637 return n | 628 return n |