I have no input on the exact question you asked, but I wonder if you can at least reduce how much you use your hands by using DragonSpeak or whatever for email and writing these postings. Presumably a large chunk of your typing is non-programming, so you may at least reduce your pain. Good luck. DB
dburns
Posts
-
voice programming? -
Stupid PC tricksThese were on X-windows terminals, but in the same spirit. Once you know the display ID they tend to be pretty open, so I got the ID for someone down the hall... 1) Turn screen black after 1 second of inactivity. 2) (later same day) Turn key-click volume from zero to full. As soon as I hit return the office was filled with CLACK CLACK CLACK (pause) CLACK CLACK (longer pause)... Although it's untraceable the victim immediately showed up at my door for some reason. :)
-
12-21-2012code-frog wrote:
ancient Aztec's, Chinese, Hopi, WebBot
The ancient WebBot? I didn't know the ancients had WebBots. I'm sure they were very primitive by today's standards :-)
code-frog wrote:
12-21-2012 being the "last day".
A bunch of people were saying that about the year 2000. Unfortunately I missed the opportunity to bet my life's savings against theirs that it wouldn't happen. Maybe I can do that in 2012 if I can find an Aztec or someone else who believes the world will end. I figure it's a pretty safe bet because we'll all be dead if I'm wrong anyway.
-
differentiating between literal strings and char pointers [modified]:-) Kind of funny you should suggest that, because that's almost exactly what we have today. Once our string type has copied data from a buffer, then it is ref-counted to avoid further copies. We have a means to specify that the input string is a literal quoted string, in which case no copy of the string data is made at all (and ref-counting is not needed). However in most cases programmers seem to use the version that copies string data even when they're supplying a literal quoted string. No reason other than they have other things on their mind when writing code, and don't seem to remember such details. So my goal was to detect this and either automatically be more efficient, or give them a compiler error that forces them to use the more efficient version. As an update I've found I can use "const" to detect the use of a non-literal buffer in some cases, but not all. For example:
char buff[100]; ... StringClass s1(buff); // Works: will use the non-const constructor and will copy. const char* ptr = ...; // possibly points at some local temp buffer StringClass s2(ptr); // Can't distinguish between this case... StringClass s3("hello"); //... and this case
So I would like to distinguish between the s2 and the s3 case (the s2 case should be copied since there's no telling where the pointer is pointing, and the s3 case should not be copied). I don't think C++ is going to let me do that. Thanks for the ideas... -
differentiating between literal strings and char pointers [modified]Now that's outside-the-box thinking!! I think I'm a little chicken to go that route though...
-
differentiating between literal strings and char pointers [modified]CPallini wrote:
Or are you're talking about an internal copy done by you're class?
Yes, that's exactly right. Perhaps you've illustrated it better than I did in the original post. However, I can't use foo and foo_without_copy. In the OP I indicated that I can't have the caller make the explicit choice. I need the compiler to differentiate, if it's possible. I doubt it is. Maybe I'm just lazy but we're talking a million lines of code here and I'd rather the compiler did the work rather than me searching and changing each one :-)
-
differentiating between literal strings and char pointers [modified]David,
DavidCrow wrote:
Why use p_buff when you can pass buff directly to the foo() method?
I could have passed buff in directly, yes. What I was trying to illustrate is that the input parameter might actually be a
const char*
pointer, but in that case I don't know where the underlying data came from. It could be from a buffer, as in the example, so I would have to copy the data in this case. Unfortunately, a "quoted string" is also aconst char*
pointer, so it would naturally choose the same overridden foo. But if it's a "quoted string" then I don't have to copy the underlying data, so the goal is to differentiate between these two cases. Like I said, probably not possible in C++, just checking. DB -
differentiating between literal strings and char pointers [modified]We really DO need to copy the data because the C++ object that I called "myclass" may outlive the buffer that contained the original data. If we just stored the supplied pointer, then it would be pointing to a buffer on the stack, which would be wiped out when the function returned. Then the "myclass" object would have a pointer to garbage. If the pointer is truly a "literal string" then that's not an issue. That's why I'm trying to detect that case to be more efficient.
-
differentiating between literal strings and char pointers [modified]CPallini wrote:
IMHO, You completely miss the efficience target...
Actually we've done profiling on this code and it really does matter. You may be picturing one or two invocations but picture 10s of millions :-)
-
Retrieve the length of an intPerspx wrote:
...don't manage resources well
Don't forget, memory is not the only resource a computer has. Sounds to me like you're wasting the CPU time (another resource) in order to save a few bytes of memory. It's hard to imagine a case where those few bytes would ever matter. There's also the factor of code complexity -- sounds like you're making your code more complex than it needs to be. Since you're calculating size, I'd guess you're going to be allocating memory dynamically through malloc or new[] etc. Those schemes will add their own overhead which will swamp the few bytes you're aiming to save.
Perspx wrote:
Don't you agree?
In principal, yes, don't waste resources. However, I think you're going overboard in this case (the other posts seem to agree).
-
differentiating between literal strings and char pointers [modified]Hi, Suppose I have a method foo that takes a const char* param. I have a case where I can be more efficient if the caller passes in a "quoted literal string" vs the contents of some arbitrary buffer (because I don't have to copy the string data in the first case). ((UPDATE: To be clear, the class with method foo needs to store the supplied string away for later access, internally. For a literal string, it's safe to store the pointer only. For a non-literal, it's necessary to copy the data in case the original caller's buffer goes away or is modified before the class instance goes away.)) Pretty sure the answer is "you can't", but I thought I'd check if anyone can think of a way to overload the method foo such that one version is invoked for
char buff[100]; ... const char* p_buff = buff; myclass.foo(p_buff)
and the second version is invoked formyclass.foo("literal string")
? I can't change the name of foo or have the caller specify explicitly which one they want. This sample is just an illustration. Thanks! DB -- modified at 12:11 Friday 3rd August, 2007 -
Developing components with a non-admin accountAh, finally got it set up the way I wanted. I had already hunted in the project for regsvr32, or any sort of post-build step, but the registration was happening intrinsically. I finally found an option "Register Output" in the link options. Set that to false and got halfway there. On the occasions where I need to register it, I could log in as admin, but instead I just run a batch file that contains this: runas /noprofile /user:admin_user "\windows\system32\regsvr32.exe full_path_to_control.dll" where admin_user is the name of the admin user. I'm prompted for the password. So now I'm happy. Thanks for the links, that was enough to get me thinking along the right lines.
-
Developing components with a non-admin accountStuart, Thanks a lot for the links. I searched CodeProject before posting but apparently I suck at that too :) BTW about having the same admin privileges as your users, I tend to agree with you on the grounds that it makes for better software -- because the developers feel the pain that the users do. It's similar to the issue that developers tend to have high-end liquid-cooled hotrod systems that are 10x as fast as their customers'. Then we wonder why customers say the product is slow. Not gonna give up my machine though :cool:
-
Developing components with a non-admin accountHey Mike, Sorry if that came out wrong. I was trying to be careful to phrase things in a non-offensive way, but apparently I suck at that. By "I see no reason" I wasn't saying there weren't any, I was just saying that I'm not aware of them. I intended that to be an opening for you or anyone else to provide an example. I guess I should have said "what are the reasons" instead.
led mike wrote:
Hopefully I can remember to avoid answering your posts in the future
Please don't do that! It's just a misunderstanding. I do appreciate input of any sort. Sorry for any bruised feelings. DB
-
Developing components with a non-admin accountled mike wrote:
The activity of developing software typically requires administrator privileges
I'm not sure I'd agree with that statement. With the exception of registering COM objects, I see no reason why admin privileges are needed for software developement. Basically developing non-COM code requires the ability to edit/create files. BTW I'm talking about my own machine here, so I can easily give my account admin privileges -- but I'm trying to keep my normal account non-admin so I minimize damage from either myself or worms etc. Anyway, just looking for any tips in case someone has gone this route before.
-
Developing components with a non-admin accountHi, If you use the VS wizard to create your own ATL-based COM object, the post-build step will register the object. The problem is, that registration step fails if you're not administrator on your machine (since it requires full access to the registry). My normal day-to-day account is non-admin for security reasons. Has anyone found a good solution to this? I don't mind registering the object on occasion (with the admin account), but 99% of the time I'm changing functionality and not changing anything about the registration itself. Maybe there's a way to skip the registration process? I couldn't see a way since VS seems to do it automatically rather than with an explicit build step. Thanks for any ideas, DB
-
What do you do?Why thank you, and while I don't deny any claims of being brilliant :-) it's a fairly common technique. The CWaitCursor MFC class uses it to turn on and off the wait cursor automatically. It's also handy to free up resources (memory, files, whatever). In an unmanaged language like C++ this is a very important technique if you're using exceptions, since an exception can cause a resource leak otherwise.
-
What do you do?Oh BTW I just hacked this tidbit together for tracing. I'll just throw it out there in case someone finds it useful. Obviously I was completely hacking... #include class FT { public: FT(const char* pcFunc) : mpcFunc(pcFunc) { printf("Enter %s\n", mpcFunc); } ~FT() { printf("Exit %s\n", mpcFunc); } const char* mpcFunc; }; #define __TR FT oFT(__FUNCSIG__); void function() { __TR } That will spit out enter/exit messages for each function that has the __TR macro.
-
What do you do?I'm not vouching for it (haven't tried it) but there's a "black box" product out there at http://www.identify.com/products/index.php[^]. I have no idea if it will help but a product like this may help. Depending on the product, it's sometimes a good idea for the product to support tracing. Then in cases like this you ask the customer to enable it and send you the log. If you don't already support tracing, you could send the customer a hacked-up version that traces to a log.
-
[Message Deleted]That's weird that they claim that it lacks any OCR! Because I just tried hand-scribbling some text in Paint, and it came very close to guessing the word (eg I scribbled phone and it got hone). I tried using actual text in Paint, then skewing it a few degrees, and it was still able to read it. So it certainly seems to be doing quite good OCR. Maybe that quoted article is out of date.