delete[] template error

Started by
36 comments, last by EvilCrap 22 years, 1 month ago
aww, i wish evilcrap would show up and make more outlandish claims. It''s so much more fun debunking them than doing my homework =P
Advertisement
quote:Original post by EvilCrap
ap, you must be a moron.

i knew the problem was with delete in the destructor

That''s true, but you didn''t know how to fix it.

In the first post you said
quote:man, ive been screwing with this error for liek a week.

For a week, eh? But right after someone posts the solution here, you come claiming that you had suddenly solved it without anyone''s help.

Well, anyone can make their own conclusions. Mine is most likely the truth
sjelkjd: i dont know if its ur computer, compiler, or maybe that u cant multiply.

i ran this on a number of different computers:
    void test1(float &t1,float &t2){	int c1=0,c2=0;		t1 = GetTickCount();	for(int i=0;i<999999;i++)	{		CfastString<int> fStr1("nickkasdfa");		CfastString<int> fStr2("nickkasdfa");		if (fStr1.compare (fStr2) ) c1++;		}		t2 = GetTickCount() - t1;}void test2(float &t1,float &t2){	int c1=0,c2=0;	t1 = GetTickCount();	for(int i=0;i<999999;i++)	{		string f1("nickkasdfa");		string f2("nickkasdfa");		if(f1==f2) c2++;	}	t2 = GetTickCount() - t1;}int main(int argc, char* argv[]){			float one=0,two=0;	cout << "running fstr" << endl;	for(int i=0;i<5;i++)	{		test1(one,two);	}	cout << two << endl;	one=two=0;	cout << "running str" << endl;	for( i=0;i<5;i++)	{		test2(one,two);	}	cout<<two<<endl;	cin.get();	return 0;}      	    

and each time fastString was about 1.9 times faster.
why dont u go do homework.
the only reason fastString might slow in ur example is that the fastString char* constructor is probably slower than the std string char* constructor; since you have it scoped to that for loop.

and int can get slow on long strings, inwhich case you switch to double.

AND DONT SAY U CORRECTED MY CODE BY ADDING CRAP! THAT AINT BY NO MEANS COMPLETE SOURCE ( as i already stated), U FREAKING DORK.


Edited by - evilcrap on February 25, 2002 4:15:51 PM
and i hadnt been working on it for ''like a week'', i actually started it on like sunday or somthign. i just said that cuase i thought id get more replies.

and its not like i spent 8 hrs on it a day either, i could work on it for a year -that doesnt mean i put an hour of work into it.
Somehow i don''t believe your "benchmarking" efforts. Maybe it''s the lack of concrete numbers. Maybe it''s the lack of machine specs. Maybe it''s your general lack of credibility.
quote:
and int can get slow on long strings, inwhich case you switch to double.

Long strings! You think 10 characters is a long string! HAHAHAHAHAHAHAHAHAHAHAHAHA that doesn''t even deserve a response.


quote:
the only reason fastString might slow in ur example is that the fastString char* constructor is probably slower than the std string char* constructor; since you have it scoped to that for loop.

Why would that be? I thought you had a fast string?
Well, since you apparently don''t believe me, here''s what I added to your "fast" string:

  CfastString& operator=(const CfastString& rhs)	{		delete[] _pStringStart;			_pStringStart = NULL; _pStringEnd = NULL;			set((char*)rhs._pStringEnd);		return *this;	}	CfastString(const CfastString& rhs)	{		_pStringStart = NULL;		_pStringEnd = NULL;			operator=(rhs);	}  

And I changed
  bool compare(CfastString fString)	  

to
  bool compare(const CfastString& fString)	  


I find it hard to take you seriously when you don''t know the difference between the two, and yet you claim to be an optimization wizard.
btw, have you looked at the source for strcpy yet? It already aligns on 4-byte boundaries!
quote:Original post by EvilCrap
and each time fastString was about 1.9 times faster.


Benchmarks devoid of usage statistics are also devoid of meaning. fastString is 1.9 times faster than std::string at what? At some arbitrary benchmark which has no basis in real world usage, presumably. This notion is sometimes referred to as "premature optimisation".

--

It is against the law to stare at the mayor of Paris.

This topic is closed to new replies.

Advertisement