[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: const char* vs. QString (was: Re: Compiling with -Wall)
From:       David Faure <david () mandrakesoft ! com>
Date:       2001-11-30 20:42:27
[Download RAW message or body]

On Friday 30 November 2001 23:05, Marc Mutz wrote:
> On Friday 30 November 2001 20:09, David Faure wrote:
> > On Friday 30 November 2001 22:06, Marc Mutz wrote:
> <snip>
> > > It's only: Why do those functions take a _QString_ as argument in
> > > the first place? I mean - is const char * considered so bad that
> > > it's not allowed as arg type?
> >
> > Yes, char * poses the problem of ownership - who deletes it, etc.
> > But on other hand, I agree that this code could make use of QCString
> > where appropriate...
> 
> Well, ss long as the functions take _const_ char * parameters, it's
> pretty clear that the owner of the string is the caller, no?

Well, then in a setBlah() you need to do a manual deep copy inside the method,
otherwise you're pointing to something you don't own.
 
> QCString's are bad because they're slow and make a deep copy when
> assigned a char*. I wonder if all those const char* -> Q(C)String ->
> const char* conversions have a measureable effect on performance. They
> had/have in KMail, for sure.

OTOH when passing a QCString to a method, and that method wants to store
it, it won't copy it, it will just use sharing.
Not everything is about passing short-lived values, that's the problem.
In any case, using QCString instead of QString for those always-latin1 things
can't make things slower.

-- 
David FAURE, david@mandrakesoft.com, faure@kde.org
http://perso.mandrakesoft.com/~david/ , http://www.konqueror.org/
KDE 3.0: Konquering the Desktops
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic