summaryrefslogtreecommitdiffstats
path: root/generic/tclPathObj.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-02-27 08:34:05 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-02-27 08:34:05 (GMT)
commitf04b875d88bbe9cd4d2114d60c194be01a7c9e04 (patch)
tree34dde540a1ed936003a721aec62cf6ede6e5bfa2 /generic/tclPathObj.c
parent4fdbe79875a43efd9f42e75ccf256884f657dac3 (diff)
downloadtcl-f04b875d88bbe9cd4d2114d60c194be01a7c9e04.zip
tcl-f04b875d88bbe9cd4d2114d60c194be01a7c9e04.tar.gz
tcl-f04b875d88bbe9cd4d2114d60c194be01a7c9e04.tar.bz2
More use of (efficient) TclHasIntRep() macro. Also eliminate many (size_t) and (unsigned) type-casts, which don't make sense any more.
Diffstat (limited to 'generic/tclPathObj.c')
-rw-r--r--generic/tclPathObj.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c
index 0532b98..3703aaf 100644
--- a/generic/tclPathObj.c
+++ b/generic/tclPathObj.c
@@ -560,9 +560,7 @@ TclPathPart(
Tcl_Obj *pathPtr, /* Path to take dirname of */
Tcl_PathPart portion) /* Requested portion of name */
{
- Tcl_ObjIntRep *irPtr = TclFetchIntRep(pathPtr, &fsPathType);
-
- if (irPtr) {
+ if (TclHasIntRep(pathPtr, &fsPathType)) {
FsPath *fsPathPtr = PATHOBJ(pathPtr);
if (PATHFLAGS(pathPtr) != 0) {
@@ -1158,8 +1156,6 @@ Tcl_FSConvertToPathType(
Tcl_Obj *pathPtr) /* Object to convert to a valid, current path
* type. */
{
- Tcl_ObjIntRep *irPtr = TclFetchIntRep(pathPtr, &fsPathType);
-
/*
* While it is bad practice to examine an object's type directly, this is
* actually the best thing to do here. The reason is that if we are
@@ -1170,7 +1166,7 @@ Tcl_FSConvertToPathType(
* path.
*/
- if (irPtr) {
+ if (TclHasIntRep(pathPtr, &fsPathType)) {
if (TclFSEpochOk(PATHOBJ(pathPtr)->filesystemEpoch)) {
return TCL_OK;
}
@@ -1481,9 +1477,8 @@ MakePathFromNormalized(
Tcl_Obj *pathPtr) /* The object to convert. */
{
FsPath *fsPathPtr;
- Tcl_ObjIntRep *irPtr = TclFetchIntRep(pathPtr, &fsPathType);
- if (irPtr) {
+ if (TclHasIntRep(pathPtr, &fsPathType)) {
return TCL_OK;
}
@@ -1684,7 +1679,7 @@ Tcl_FSGetTranslatedStringPath(
const char *orig = TclGetStringFromObj(transPtr, &len);
char *result = ckalloc(len+1);
- memcpy(result, orig, (size_t) len+1);
+ memcpy(result, orig, len+1);
TclDecrRefCount(transPtr);
return result;
}
@@ -2087,9 +2082,8 @@ TclFSEnsureEpochOk(
const Tcl_Filesystem **fsPtrPtr)
{
FsPath *srcFsPathPtr;
- Tcl_ObjIntRep *irPtr = TclFetchIntRep(pathPtr, &fsPathType);
- if (irPtr == NULL) {
+ if (!TclHasIntRep(pathPtr, &fsPathType)) {
return TCL_OK;
}
@@ -2146,13 +2140,12 @@ TclFSSetPathDetails(
ClientData clientData)
{
FsPath *srcFsPathPtr;
- Tcl_ObjIntRep *irPtr = TclFetchIntRep(pathPtr, &fsPathType);;
/*
* Make sure pathPtr is of the correct type.
*/
- if (irPtr == NULL) {
+ if (!TclHasIntRep(pathPtr, &fsPathType)) {
if (SetFsPathFromAny(NULL, pathPtr) != TCL_OK) {
return;
}
@@ -2250,9 +2243,8 @@ SetFsPathFromAny(
FsPath *fsPathPtr;
Tcl_Obj *transPtr;
char *name;
- Tcl_ObjIntRep *irPtr = TclFetchIntRep(pathPtr, &fsPathType);
- if (irPtr) {
+ if (TclHasIntRep(pathPtr, &fsPathType)) {
return TCL_OK;
}
@@ -2558,8 +2550,6 @@ TclNativePathInFilesystem(
Tcl_Obj *pathPtr,
ClientData *clientDataPtr)
{
- Tcl_ObjIntRep *irPtr = TclFetchIntRep(pathPtr, &fsPathType);
-
/*
* A special case is required to handle the empty path "". This is a valid
* path (i.e. the user should be able to do 'file exists ""' without
@@ -2567,7 +2557,7 @@ TclNativePathInFilesystem(
* semantics of Tcl (at present anyway), so we have to abide by them here.
*/
- if (irPtr) {
+ if (TclHasIntRep(pathPtr, &fsPathType)) {
if (pathPtr->bytes != NULL && pathPtr->bytes[0] == '\0') {
/*
* We reject the empty path "".