[Zope-Checkins] CVS: Packages/AccessControl - cAccessControl.c:1.20.2.17

Tim Peters tim.one at comcast.net
Tue Dec 14 11:24:24 EST 2004


Update of /cvs-repository/Packages/AccessControl
In directory cvs.zope.org:/tmp/cvs-serv16427/lib/python/AccessControl

Modified Files:
      Tag: Zope-2_7-branch
	cAccessControl.c 
Log Message:
PermissionRole_getattro():

- Repaired the indentation to reflect the block structure.

- Introduced a speed trick:  check that the first character is '_' before
  doing a chain of strcmps() that can't succeed if it isn't.


=== Packages/AccessControl/cAccessControl.c 1.20.2.16 => 1.20.2.17 ===
--- Packages/AccessControl/cAccessControl.c:1.20.2.16	Tue Dec 14 11:01:07 2004
+++ Packages/AccessControl/cAccessControl.c	Tue Dec 14 11:24:23 2004
@@ -1632,8 +1632,9 @@
 **
 */
 
-static PyObject *PermissionRole_getattro(PermissionRole *self, PyObject *name) {
-  	PyObject  *result= NULL;
+static PyObject *
+PermissionRole_getattro(PermissionRole *self, PyObject *name) {
+  	PyObject  *result = NULL;
         char      *name_s = PyString_AsString(name);
 
 	/* see whether we know the attribute */
@@ -1641,23 +1642,23 @@
 	   and the new "__roles__"
 	*/
     
-	if (name_s) {
-		if (!strcmp(name_s, "__name__")) 
-            result= self->__name__;
+	if (name_s && name_s[0] == '_') {
+		if (! strcmp(name_s, "__name__")) 
+			result = self->__name__;
 		else if (! strcmp(name_s, "__roles__"))
-            result= self->__roles__;
+			result = self->__roles__;
 		else if (! strcmp(name_s, "_p"))
-            result= self->_p;
+			result = self->_p;
 		else if (! strcmp(name_s, "_d"))
-            result= self->__roles__;
+			result= self->__roles__;
 	}
 
 	if (result) {
 		Py_INCREF(result);
 		return result;
-	} else {
-		return ExtensionClassGetattro((PyObject *)self,name);
 	}
+	else
+		return ExtensionClassGetattro((PyObject *)self,name);
 }
 
 



More information about the Zope-Checkins mailing list