[Epydoc-commits] SF.net SVN: epydoc: [1350] trunk/epydoc/src/epydoc/apidoc.py
Brought to you by:
edloper
|
From: <ed...@us...> - 2006-09-04 04:09:56
|
Revision: 1350
http://svn.sourceforge.net/epydoc/?rev=1350&view=rev
Author: edloper
Date: 2006-09-03 21:09:52 -0700 (Sun, 03 Sep 2006)
Log Message:
-----------
- Added DottedName._ok_identifiers cache. (As a profile-driven
optimization)
Modified Paths:
--------------
trunk/epydoc/src/epydoc/apidoc.py
Modified: trunk/epydoc/src/epydoc/apidoc.py
===================================================================
--- trunk/epydoc/src/epydoc/apidoc.py 2006-09-03 05:31:31 UTC (rev 1349)
+++ trunk/epydoc/src/epydoc/apidoc.py 2006-09-04 04:09:52 UTC (rev 1350)
@@ -76,6 +76,10 @@
An exception raised by the DottedName constructor when one of
its arguments is not a valid dotted name.
"""
+
+ _ok_identifiers = set()
+ """A cache of identifier strings that have been checked against
+ _IDENTIFIER_RE and found to be acceptable."""
def __init__(self, *pieces):
"""
@@ -104,13 +108,16 @@
self._identifiers += piece._identifiers
elif isinstance(piece, basestring):
for subpiece in piece.split('.'):
- if not self._IDENTIFIER_RE.match(subpiece):
- raise DottedName.InvalidDottedName(
- 'Bad identifier %r' % (piece,))
+ if piece not in self._ok_identifiers:
+ if self._IDENTIFIER_RE.match(subpiece):
+ self._ok_identifiers.add(piece)
+ else:
+ raise DottedName.InvalidDottedName(
+ 'Bad identifier %r' % (piece,))
self._identifiers.append(subpiece)
else:
- raise DottedName.InvalidDottedName(
- 'Bad identifier %r' % (piece,))
+ raise TypeError('Bad identifier %r: expected '
+ 'DottedName or str' % (piece,))
self._identifiers = tuple(self._identifiers)
def __repr__(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|