Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #151974
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: pure C90 environment |
| Date | 2020-05-03 03:55 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <87lfm94til.fsf@bsb.me.uk> (permalink) |
| References | (5 earlier) <5905a20d-97fb-4ca9-83eb-5ffba4bf2137@googlegroups.com> <r8jvjr$5sd$1@news.albasani.net> <tehrG.278453$CO1.219175@fx27.am4> <87r1w23t9p.fsf@bsb.me.uk> <fvmrG.240019$dx4.196112@fx05.am4> |
Bart <bc@freeuk.com> writes:
> On 02/05/2020 22:45, Ben Bacarisse wrote:
>> Bart <bc@freeuk.com> writes:
>>
>>> [Off the topic of pure C90]
>>>
>>> On 02/05/2020 15:20, Bonita Montero wrote:
>>>>> How expressive and how simple.
>>>>
>>>> Simplicity mostly contraticts expressiveness.
>>>
>>> Remember the strrepl thread? My scripting solution can be expressed like this:
>>>
>>> function strrepl(s, old, new)=
>>> t := ""
>>> while n:=old in s do
>>> t +:= s[1..n-1] + new
>>> s := s[n+old.len..$]
>>> od
>>> return t+s
>>> end
>>
>> This can be written in C++ like this:
>>
>> using std::string;
>>
>> string replace(const string &str, const string &pat, const string &rep)
>> {
>> string result;
>> string::size_type pos = 0, start;
>> while ((start = str.find(pat, pos)) != string::npos) {
>> result += str.substr(pos, start - pos) + rep;
>> pos = start + pat.length();
>> }
>> return result + str.substr(pos);
>> }
>>
>> It need not be as complicated as some of the posted code.
>>
>
> That's not too bad. Certainly it is smaller and simpler than anything
> I remember Bonita posting.
>
> Yet, it's not quite as clean as the dynamic code,
Your code appears to have some string operations built-in. It's even
simpler written in a language that has lots of string operations
built-in. In Perl it's just
s/$old/$new/g
> and I had some fun trying to figure out how to pass such a string to
> fwrite.
Well, it's an odd thing to do, so I am not surprised by that.
> (Also, on a machine which doesn't support the SSE ops needed for fast
> string search, it was still 25% slower than my interpreter running
> that script.)
All the "simple" versions posted are little more then drivers for the
underlying operations of string searching and copying. On my system,
your code is slow simply because the "in" operator is not implemented as
well as it could be for that target. And my C version is slow on your
system because strstr is not well implemented in the C implementation
you use. On my machine, the C++ code is slower than the C code but
faster than yours. All that does is reflect the implementation of the
underlying operations.
--
Ben.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-01 22:19 -0700
Re: pure C90 environment fir <profesor.fir@gmail.com> - 2020-05-02 01:24 -0700
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-02 01:56 -0700
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-02 02:06 -0700
Re: pure C90 environment shi84516584@gmail.com - 2020-05-19 17:53 -0700
Re: pure C90 environment fir <profesor.fir@gmail.com> - 2020-05-02 02:07 -0700
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-02 02:23 -0700
Re: pure C90 environment shi84516584@gmail.com - 2020-05-19 17:55 -0700
Re: pure C90 environment Philipp Klaus Krause <pkk@spth.de> - 2020-05-02 11:05 +0200
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-02 02:14 -0700
Re: pure C90 environment antispam@math.uni.wroc.pl - 2020-05-03 22:33 +0000
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-03 16:18 -0700
Re: pure C90 environment antispam@math.uni.wroc.pl - 2020-05-04 00:35 +0000
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-03 17:54 -0700
Re: pure C90 environment Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-05-03 18:38 -0700
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-03 18:51 -0700
Re: pure C90 environment David Brown <david.brown@hesbynett.no> - 2020-05-04 09:36 +0200
Re: pure C90 environment James Harris <james.harris.1@gmail.com> - 2020-05-04 08:48 +0100
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-04 01:12 -0700
Re: pure C90 environment David Brown <david.brown@hesbynett.no> - 2020-05-04 15:16 +0200
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-04 06:21 -0700
Re: pure C90 environment David Brown <david.brown@hesbynett.no> - 2020-05-04 15:40 +0200
Re: pure C90 environment Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-05-04 07:12 -0700
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-04 14:47 +0100
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-04 07:08 -0700
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-04 08:12 -0700
Re: pure C90 environment BGB <cr88192@gmail.com> - 2020-05-05 11:36 -0500
Re: pure C90 environment James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-05-19 11:25 -0400
Re: pure C90 environment James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-05-19 11:39 -0400
Re: pure C90 environment Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-05-19 08:45 -0700
Re: pure C90 environment David Brown <david.brown@hesbynett.no> - 2020-05-19 17:43 +0200
Re: pure C90 environment James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-05-19 12:35 -0400
Re: pure C90 environment David Brown <david.brown@hesbynett.no> - 2020-05-19 20:14 +0200
Re: pure C90 environment James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-05-19 14:42 -0400
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-19 12:11 -0700
Re: pure C90 environment David Brown <david.brown@hesbynett.no> - 2020-05-19 21:46 +0200
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-19 13:11 -0700
Re: pure C90 environment Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-05-19 14:39 -0700
Re: pure C90 environment Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-05-19 13:24 -0700
Re: pure C90 environment David Brown <david.brown@hesbynett.no> - 2020-05-20 09:26 +0200
Re: pure C90 environment antispam@math.uni.wroc.pl - 2020-05-19 21:11 +0000
Re: pure C90 environment James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-05-19 18:51 -0400
Re: pure C90 environment antispam@math.uni.wroc.pl - 2020-05-19 23:26 +0000
Re: pure C90 environment David Brown <david.brown@hesbynett.no> - 2020-05-20 09:33 +0200
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-04 11:49 +0100
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-04 04:00 -0700
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-04 17:58 +0100
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-04 10:18 -0700
Re: pure C90 environment Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-05-04 13:57 -0700
Re: pure C90 environment Bonita Montero <Bonita.Montero@gmail.com> - 2020-05-02 12:11 +0200
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-02 11:26 +0100
Re: pure C90 environment Bonita Montero <Bonita.Montero@gmail.com> - 2020-05-02 13:06 +0200
Re: pure C90 environment Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-05-02 04:26 -0700
Re: pure C90 environment fir <profesor.fir@gmail.com> - 2020-05-02 04:53 -0700
Re: pure C90 environment Bonita Montero <Bonita.Montero@gmail.com> - 2020-05-02 16:21 +0200
Re: pure C90 environment fir <profesor.fir@gmail.com> - 2020-05-02 11:20 -0700
Re: pure C90 environment Bonita Montero <Bonita.Montero@gmail.com> - 2020-05-02 16:20 +0200
Re: pure C90 environment Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-05-02 07:33 -0700
Re: pure C90 environment Bonita Montero <Bonita.Montero@gmail.com> - 2020-05-02 16:35 +0200
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-02 17:30 +0100
Re: pure C90 environment Bonita Montero <Bonita.Montero@gmail.com> - 2020-05-02 18:37 +0200
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-02 18:18 +0100
Re: pure C90 environment Bonita Montero <Bonita.Montero@gmail.com> - 2020-05-02 19:25 +0200
Re: pure C90 environment Bonita Montero <Bonita.Montero@gmail.com> - 2020-05-02 19:25 +0200
Re: pure C90 environment Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-05-02 22:45 +0100
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-02 23:29 +0100
Re: pure C90 environment Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-05-03 03:55 +0100
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-03 13:07 +0100
Re: pure C90 environment fir <profesor.fir@gmail.com> - 2020-05-03 05:24 -0700
Re: pure C90 environment Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-05-03 05:26 -0700
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-03 14:27 +0100
Re: pure C90 environment Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-05-03 22:38 +0100
Re: pure C90 environment Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-05-03 22:06 +0100
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-04 00:28 +0100
Re: pure C90 environment Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-05-03 02:16 -0700
Re: pure C90 environment Öö Tiib <ootiib@hot.ee> - 2020-05-03 16:23 -0700
Re: pure C90 environment Bonita Montero <Bonita.Montero@gmail.com> - 2020-05-04 16:41 +0200
Re: pure C90 environment Bonita Montero <Bonita.Montero@gmail.com> - 2020-05-04 16:59 +0200
Re: pure C90 environment Öö Tiib <ootiib@hot.ee> - 2020-05-04 11:01 -0700
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-02 11:13 +0100
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-02 03:53 -0700
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-02 05:14 -0700
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-02 06:30 -0700
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-02 12:49 -0700
Re: pure C90 environment Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-05-13 03:01 -0700
Re: pure C90 environment scott@slp53.sl.home (Scott Lurndal) - 2020-05-13 14:43 +0000
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-17 06:30 -0700
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-17 05:41 -0700
Re: pure C90 environment Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-05-17 13:02 -0700
Re: pure C90 environment David Brown <david.brown@hesbynett.no> - 2020-05-17 22:47 +0200
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-17 14:03 -0700
Re: pure C90 environment David Brown <david.brown@hesbynett.no> - 2020-05-18 08:54 +0200
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-18 06:11 -0700
Re: pure C90 environment Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-05-18 06:51 -0700
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-18 07:12 -0700
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-18 15:47 +0100
Re: pure C90 environment Manfred <noname@add.invalid> - 2020-05-18 16:25 +0200
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-18 07:41 -0700
Re: pure C90 environment Manfred <noname@add.invalid> - 2020-05-18 17:32 +0200
Re: pure C90 environment David Brown <david.brown@hesbynett.no> - 2020-05-18 17:09 +0200
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-18 08:52 -0700
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-18 17:05 +0100
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-18 09:18 -0700
Re: pure C90 environment scott@slp53.sl.home (Scott Lurndal) - 2020-05-18 19:55 +0000
Re: pure C90 environment Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-05-19 01:42 +0100
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-18 20:35 -0700
Re: pure C90 environment scott@slp53.sl.home (Scott Lurndal) - 2020-05-19 16:12 +0000
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-19 10:02 -0700
Re: pure C90 environment scott@slp53.sl.home (Scott Lurndal) - 2020-05-19 17:42 +0000
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-19 18:16 +0100
Re: pure C90 environment David Brown <david.brown@hesbynett.no> - 2020-05-19 13:00 +0200
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-19 05:09 -0700
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-19 15:20 +0100
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-19 08:18 -0700
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-19 17:58 +0100
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-19 10:45 -0700
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-19 19:31 +0100
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-19 11:58 -0700
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-19 20:44 +0100
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-19 13:03 -0700
Re: pure C90 environment antispam@math.uni.wroc.pl - 2020-05-19 22:34 +0000
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-19 15:41 -0700
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-20 00:03 +0100
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-19 16:10 -0700
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-20 01:46 +0100
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-19 22:49 -0700
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-20 11:26 +0100
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-20 04:43 -0700
Re: pure C90 environment Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-05-19 16:40 -0700
Re: pure C90 environment antispam@math.uni.wroc.pl - 2020-05-19 23:11 +0000
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-19 11:40 -0700
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-20 05:48 -0700
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-20 06:19 -0700
Re: pure C90 environment Bart <bc@freeuk.com> - 2020-05-20 16:38 +0100
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-20 09:15 -0700
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-20 09:37 -0700
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-20 10:43 -0700
Re: pure C90 environment Öö Tiib <ootiib@hot.ee> - 2020-05-20 10:58 -0700
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-20 11:36 -0700
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-20 12:37 -0700
Re: pure C90 environment "muta...@gmail.com" <mutazilah@gmail.com> - 2021-03-10 17:43 -0800
Re: pure C90 environment "muta...@gmail.com" <mutazilah@gmail.com> - 2021-03-10 17:58 -0800
Re: pure C90 environment "muta...@gmail.com" <mutazilah@gmail.com> - 2021-03-10 18:03 -0800
Re: pure C90 environment "muta...@gmail.com" <mutazilah@gmail.com> - 2021-03-10 18:29 -0800
Re: pure C90 environment "muta...@gmail.com" <mutazilah@gmail.com> - 2021-03-10 19:54 -0800
Re: pure C90 environment "muta...@gmail.com" <mutazilah@gmail.com> - 2021-03-10 20:01 -0800
Re: pure C90 environment "muta...@gmail.com" <mutazilah@gmail.com> - 2021-03-10 20:04 -0800
Re: pure C90 environment "muta...@gmail.com" <mutazilah@gmail.com> - 2021-03-10 21:07 -0800
Re: pure C90 environment Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-03-10 23:10 -0800
Re: pure C90 environment "muta...@gmail.com" <mutazilah@gmail.com> - 2021-03-11 01:21 -0800
Re: pure C90 environment scott@slp53.sl.home (Scott Lurndal) - 2021-03-11 15:26 +0000
Re: pure C90 environment David Brown <david.brown@hesbynett.no> - 2020-05-19 17:18 +0200
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-19 09:52 -0700
Re: pure C90 environment scott@slp53.sl.home (Scott Lurndal) - 2020-05-19 17:39 +0000
Re: pure C90 environment scott@slp53.sl.home (Scott Lurndal) - 2020-05-19 16:17 +0000
Re: pure C90 environment Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-05-19 22:54 +0100
Re: pure C90 environment Ian Collins <ian-news@hotmail.com> - 2020-05-20 10:17 +1200
Re: pure C90 environment Manfred <noname@add.invalid> - 2020-05-19 16:28 +0200
Re: pure C90 environment David Brown <david.brown@hesbynett.no> - 2020-05-19 17:30 +0200
Re: pure C90 environment Manfred <noname@add.invalid> - 2020-05-19 19:39 +0200
Re: pure C90 environment antispam@math.uni.wroc.pl - 2020-05-18 15:12 +0000
Re: pure C90 environment scott@slp53.sl.home (Scott Lurndal) - 2020-05-18 19:51 +0000
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-18 13:02 -0700
Re: pure C90 environment Manfred <noname@add.invalid> - 2020-05-18 15:52 +0200
Re: pure C90 environment David Brown <david.brown@hesbynett.no> - 2020-05-18 17:15 +0200
Re: pure C90 environment antispam@math.uni.wroc.pl - 2020-05-18 20:10 +0000
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-18 13:18 -0700
Re: pure C90 environment antispam@math.uni.wroc.pl - 2020-05-18 23:21 +0000
Re: pure C90 environment David Brown <david.brown@hesbynett.no> - 2020-05-19 13:21 +0200
Re: pure C90 environment David Brown <david.brown@hesbynett.no> - 2020-05-19 13:12 +0200
Re: pure C90 environment scott@slp53.sl.home (Scott Lurndal) - 2020-05-19 16:21 +0000
Re: pure C90 environment scott@slp53.sl.home (Scott Lurndal) - 2020-05-18 19:48 +0000
Re: pure C90 environment scott@slp53.sl.home (Scott Lurndal) - 2020-05-18 19:47 +0000
Re: pure C90 environment David Brown <david.brown@hesbynett.no> - 2020-05-19 13:23 +0200
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-17 13:54 -0700
Re: pure C90 environment Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-05-17 16:45 -0700
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-17 17:27 -0700
Re: pure C90 environment antispam@math.uni.wroc.pl - 2020-05-18 14:44 +0000
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-18 08:17 -0700
Re: pure C90 environment antispam@math.uni.wroc.pl - 2020-05-18 21:39 +0000
Re: pure C90 environment scott@slp53.sl.home (Scott Lurndal) - 2020-05-18 21:58 +0000
Re: pure C90 environment Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-05-18 16:40 -0700
Re: pure C90 environment scott@slp53.sl.home (Scott Lurndal) - 2020-05-19 00:22 +0000
Re: pure C90 environment antispam@math.uni.wroc.pl - 2020-05-19 00:27 +0000
Re: pure C90 environment scott@slp53.sl.home (Scott Lurndal) - 2020-05-19 16:10 +0000
Re: pure C90 environment Paul Edwards <mutazilah@gmail.com> - 2020-05-18 14:59 -0700
Re: pure C90 environment scott@slp53.sl.home (Scott Lurndal) - 2020-05-18 20:01 +0000
Re: pure C90 environment Ian Collins <ian-news@hotmail.com> - 2020-05-18 13:25 +1200
csiph-web