June 08, 2004
Walter wrote:

<snip>
>> And have you actually seen my functions to fix bit array slicing?
>>
>> http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/313
> 
> 
> It fixes it by making a copy. I'm not sure this is the right approach, since
> all the other array slicing points to the original.

Well, just after I posted it, there was a bit of a debate over this and the alternative: modifying the representation of a bit[] to include a bit offset.

http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/2524

But you can't please all of the people (or programs) all of the time. Copying would break generic programming as far as slices would no longer be necessarily into the original array.  (Obviously, this discrepancy would need to be clearly documented.)  But it wouldn't break any existing, working programs, since bit slicing doesn't work at this time.  (Assuming that the GDC crowd haven't created their own fix....)

OTOH, code that casts bit arrays to pointers would fall apart if we introduced bit offsets.  Maybe we'd need to either disallow such casts or allow them only along with some 'byteAlign' property that returns either the original array (if already byte-aligned) or a copy.

Maybe we could start a vote.  Put me down as a 'don't know'....

Even if we do take the bit offset path, it wouldn't be tricky to adapt my functions to this representation.  Of course, we'd need access to the internals.  Maybe (as I think I've seen in some of the internal modules dealing with general arrays) they'd be modified to take a struct representing the internal representation of a bit[], rather than the bit[] itself.

Stewart.

-- 
My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment.  Please keep replies on the 'group where everyone may benefit.
June 08, 2004
In article <ca4pg0$1tfs$1@digitaldaemon.com>, Walter says...
>
>
>"Stewart Gordon" <smjg_1998@yahoo.com> wrote in message news:ca459b$pbu$1@digitaldaemon.com...
>
>> And any particular reason for not inventing a whole new operator or two for stream I/O, as I briefly suggested?
>>
>> http://www.digitalmars.com/drn-bin/wwwnews?D/25096
>
>I still think there's got to be a better way.

Me too, but darned if I've come up with the answer so far.  But if push comes to shove I do prefer:

ostream << a << b << c;

to:

print( ostream, a );
print( ostream, b );
print( ostream, c );

I'm going to play around with the possibilities in the next few days and see if I can't come up with an alternative :p


Sean


June 08, 2004
I'l be watching for your alternative Sean ...

"Sean Kelly" <sean@f4.ca> wrote in message news:ca4sn3$231k$1@digitaldaemon.com...
> In article <ca4pg0$1tfs$1@digitaldaemon.com>, Walter says...
> >
> >
> >"Stewart Gordon" <smjg_1998@yahoo.com> wrote in message news:ca459b$pbu$1@digitaldaemon.com...
> >
> >> And any particular reason for not inventing a whole new operator or two for stream I/O, as I briefly suggested?
> >>
> >> http://www.digitalmars.com/drn-bin/wwwnews?D/25096
> >
> >I still think there's got to be a better way.
>
> Me too, but darned if I've come up with the answer so far.  But if push
comes to
> shove I do prefer:
>
> ostream << a << b << c;
>
> to:
>
> print( ostream, a );
> print( ostream, b );
> print( ostream, c );
>
> I'm going to play around with the possibilities in the next few days and
see if
> I can't come up with an alternative :p
>
>
> Sean
>
>


June 08, 2004
My thought as well was to include a starting bit offset. The downside to this is the performance loss.

"Stewart Gordon" <smjg_1998@yahoo.com> wrote in message news:ca4sd9$22j1$1@digitaldaemon.com...
> Well, just after I posted it, there was a bit of a debate over this and the alternative: modifying the representation of a bit[] to include a bit offset.
>
> http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/2524
>
> But you can't please all of the people (or programs) all of the time.
> Copying would break generic programming as far as slices would no longer
> be necessarily into the original array.  (Obviously, this discrepancy
> would need to be clearly documented.)  But it wouldn't break any
> existing, working programs, since bit slicing doesn't work at this time.
>   (Assuming that the GDC crowd haven't created their own fix....)
>
> OTOH, code that casts bit arrays to pointers would fall apart if we introduced bit offsets.  Maybe we'd need to either disallow such casts or allow them only along with some 'byteAlign' property that returns either the original array (if already byte-aligned) or a copy.
>
> Maybe we could start a vote.  Put me down as a 'don't know'....
>
> Even if we do take the bit offset path, it wouldn't be tricky to adapt my functions to this representation.  Of course, we'd need access to the internals.  Maybe (as I think I've seen in some of the internal modules dealing with general arrays) they'd be modified to take a struct representing the internal representation of a bit[], rather than the bit[] itself.
>
> Stewart.
>
> -- 
> My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment.  Please keep replies on the 'group where everyone may benefit.


June 08, 2004
In article <ca4ot4$1sek$2@digitaldaemon.com>, Walter says...
>
>Thanks! I have some suggestions, though <g>. First, using toupper() allocates memory for the new string. While this works, it's better to avoid it if you can, i.e. just go through character by character and comparing that way. Second, I prefer to avoid a starting index; instead just slice the string to be searched. -Walter
>

Walter: Ok, I think I've followed your suggestions correctly. :) Please let me know if I've gotten it right, or if I'm off track somehow?

import std.c.stdio;
import std.string;

/*******************************************************************
* Function      : int ifind( in char[], in char[] )
* Author        : David L. 'SpottedTiger' Davis
* Language      : DigitalMars "D" aka Mars v0.92
* Created Date  : 03.Jun.04
* Modified Date : 08.Jun.04 Removed the wrapper function and the
*                           default parameter, mainly because the
*                           string being passed in should be already
*                           sliced so that the next search will find
*                           the matching sub-string value. Also per
*                           advice from Walter, <g> I've removed every
*                           tolower() call, and now locally all characters
*                           in the strings are set to lowercase where they
*                           sit without the need to create a another copy.
* Requirements  : std.string
* Licence       : Same as those for the Phobos (Runtime Library)
*******************************************************************
*
* Note: Meant to be a case insensitive version of std.string.find
*/
int ifind
(
in char[] sStr,
in char[] sSubStr
)
{
// If either of the string parameters are empty, return not found
if ( sStr.length < 1 || sSubStr.length < 1 ) return -1;

// sStr set to lowercase locally
// lowercase ascii a = '\x61', uppercase ascii A = '\x41'
foreach ( int iStrPos, char cChar; sStr )
sStr[ iStrPos ] = ( find( uppercase, cChar ) != -1 ) ? sStr[ iStrPos ] + 0x20 :
sStr[ iStrPos ];

// sSubStr set to lowercase locally
// lowercase ascii a = '\x61', uppercase ascii A = '\x41'
foreach ( int iStrPos, char cChar; sSubStr )
sSubStr[ iStrPos ] = ( find( uppercase, cChar ) != -1 ) ? sSubStr[ iStrPos ] +
0x20 : sSubStr[ iStrPos ];

return find( sStr, sSubStr );

} // end int ifind( in char[], in char[] )


/*******************************************************************
* Function      : int irfind( in char[], in char[] )
* Author        : David L. 'SpottedTiger' Davis
* Language      : DigitalMars "D" aka Mars v0.92
* Created Date  : 03.Jun.04
* Modified Date : 08.Jun.04 Removed the wrapper function and the
*                           default parameter, mainly because the
*                           string being passed in should be already
*                           sliced so that the next search will find
*                           the matching sub-string value. Also per
*                           advice from Walter, <g> I've removed every
*                           tolower() call, and now locally all characters
*                           in the strings are set to lowercase where they
*                           sit without the need to create a another copy.
* Requirements  : std.string
* Licence       : Same as those for the Phobos (Runtime Library)
*******************************************************************
*
* Note: Meant to be a case insensitive version of std.string.rfind.
*/
int irfind
(
in char[] sStr,
in char[] sSubStr
)
{
// If either of the string parameters are empty, return not found
if ( sStr.length < 1 || sSubStr.length < 1 ) return -1;

// sStr set to lowercase locally
// lowercase ascii a = '\x61', uppercase ascii A = '\x41'
foreach ( int iStrPos, char cChar; sStr )
sStr[ iStrPos ] = ( find( uppercase, cChar ) != -1 ) ? sStr[ iStrPos ] + 0x20 :
sStr[ iStrPos ];

// sSubStr set to lowercase locally
// lowercase ascii a = '\x61', uppercase ascii A = '\x41'
foreach ( int iStrPos, char cChar; sSubStr )
sSubStr[ iStrPos ] = ( find( uppercase, cChar ) != -1 ) ? sSubStr[ iStrPos ] +
0x20 : sSubStr[ iStrPos ];

return rfind( sStr, sSubStr );

} // end int irfind( in char[], in char[] )

// Test ifind() and irfind() to find multiples of the same sub-string
int main()
{

int    iStrPos   = 0;
int    iSlicePos = 0;
char[] sStrTest  = "ApO 123355 PO Box 23, Waterpool Street Portland, Texas";

printf( "Original = %.*s\n", sStrTest );

iStrPos   = 0;
iSlicePos = 0;

while ( iSlicePos != -1 )
{
iSlicePos = ifind( sStrTest[ iStrPos .. sStrTest.length - 1 ], "PO" );

if ( iSlicePos != -1 )
{
printf( "Found \'PO\' at position with ifind()= %d\n", iStrPos + iSlicePos );
iStrPos = iStrPos + iSlicePos + "PO".length;
}
}

printf("\n\n");

iStrPos  = sStrTest.length - 1;
iSlicePos = 0;

while ( iSlicePos != -1 && iStrPos >= 0 )
{
iSlicePos = irfind( sStrTest[ 0 .. iStrPos ], "PO" );

if ( iSlicePos != -1 )
{
printf( "Found \'PO\' at position with irfind()= %d\n", iSlicePos );
iStrPos = iSlicePos - "PO".length;
}
}

return 0;

} // end int main()

-------------------------------------------------------------------
"Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"



June 08, 2004
"Walter" <newshound@digitalmars.com> wrote in message news:ca54d7$2gmg$1@digitaldaemon.com...
> My thought as well was to include a starting bit offset. The downside to this is the performance loss.

But if bit slicing would work then, then it isn't a loss but a gain!

> "Stewart Gordon" <smjg_1998@yahoo.com> wrote in message news:ca4sd9$22j1$1@digitaldaemon.com...
> > Well, just after I posted it, there was a bit of a debate over this and the alternative: modifying the representation of a bit[] to include a bit offset.
> >
> > http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/2524
> >
> > But you can't please all of the people (or programs) all of the time.
> > Copying would break generic programming as far as slices would no longer
> > be necessarily into the original array.  (Obviously, this discrepancy
> > would need to be clearly documented.)  But it wouldn't break any
> > existing, working programs, since bit slicing doesn't work at this time.
> >   (Assuming that the GDC crowd haven't created their own fix....)
> >
> > OTOH, code that casts bit arrays to pointers would fall apart if we introduced bit offsets.  Maybe we'd need to either disallow such casts or allow them only along with some 'byteAlign' property that returns either the original array (if already byte-aligned) or a copy.
> >
> > Maybe we could start a vote.  Put me down as a 'don't know'....
> >
> > Even if we do take the bit offset path, it wouldn't be tricky to adapt my functions to this representation.  Of course, we'd need access to the internals.  Maybe (as I think I've seen in some of the internal modules dealing with general arrays) they'd be modified to take a struct representing the internal representation of a bit[], rather than the bit[] itself.
> >
> > Stewart.
> >
> > --
> > My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment.  Please keep replies on the 'group where everyone may benefit.
>
>


June 08, 2004
In article <ca55jc$2ika$1@digitaldaemon.com>, Ivan Senji says...
>
>"Walter" <newshound@digitalmars.com> wrote in message news:ca54d7$2gmg$1@digitaldaemon.com...
>> My thought as well was to include a starting bit offset. The downside to this is the performance loss.
>
>But if bit slicing would work then, then it isn't a loss but a gain!

I don't think Walter will have any problem getting bit slicing to work. Both Stewart and myself have our own workarounds (his by copy, mine by reference), so it's obviously easily doable.

The bit SLICE (or bit array, depending on your point of view) was never a problem (apart from the bugs). The bit /itself/ is the problem. Walter's suggestion will make bit slicing work, but the code below will still fall over:

>       bit[] b;
>       b.length = 64;
>       bit* p = &b[3];
>       *p = 1;

Anywhere where you get a pointer to a bit, or a reference to a bit (and this includes passing a bit as an out or inout function parameter) you get a problem. However, if Walter could make all of these situations compile-errors, he may have got it sussed!

Jill


June 08, 2004
The function uppercases the input string. It shouldn't modify its inputs.

"David L. Davis" <SpottedTiger@yahoo.com> wrote in message news:ca54is$2h2r$1@digitaldaemon.com...
> In article <ca4ot4$1sek$2@digitaldaemon.com>, Walter says...
> >
> >Thanks! I have some suggestions, though <g>. First, using toupper() allocates memory for the new string. While this works, it's better to
avoid
> >it if you can, i.e. just go through character by character and comparing that way. Second, I prefer to avoid a starting index; instead just slice
the
> >string to be searched. -Walter
> >
>
> Walter: Ok, I think I've followed your suggestions correctly. :) Please
let me
> know if I've gotten it right, or if I'm off track somehow?
>
> import std.c.stdio;
> import std.string;
>
> /*******************************************************************
> * Function      : int ifind( in char[], in char[] )
> * Author        : David L. 'SpottedTiger' Davis
> * Language      : DigitalMars "D" aka Mars v0.92
> * Created Date  : 03.Jun.04
> * Modified Date : 08.Jun.04 Removed the wrapper function and the
> *                           default parameter, mainly because the
> *                           string being passed in should be already
> *                           sliced so that the next search will find
> *                           the matching sub-string value. Also per
> *                           advice from Walter, <g> I've removed every
> *                           tolower() call, and now locally all characters
> *                           in the strings are set to lowercase where they
> *                           sit without the need to create a another copy.
> * Requirements  : std.string
> * Licence       : Same as those for the Phobos (Runtime Library)
> *******************************************************************
> *
> * Note: Meant to be a case insensitive version of std.string.find
> */
> int ifind
> (
> in char[] sStr,
> in char[] sSubStr
> )
> {
> // If either of the string parameters are empty, return not found
> if ( sStr.length < 1 || sSubStr.length < 1 ) return -1;
>
> // sStr set to lowercase locally
> // lowercase ascii a = '\x61', uppercase ascii A = '\x41'
> foreach ( int iStrPos, char cChar; sStr )
> sStr[ iStrPos ] = ( find( uppercase, cChar ) != -1 ) ? sStr[ iStrPos ] +
0x20 :
> sStr[ iStrPos ];
>
> // sSubStr set to lowercase locally
> // lowercase ascii a = '\x61', uppercase ascii A = '\x41'
> foreach ( int iStrPos, char cChar; sSubStr )
> sSubStr[ iStrPos ] = ( find( uppercase, cChar ) != -1 ) ? sSubStr[
iStrPos ] +
> 0x20 : sSubStr[ iStrPos ];
>
> return find( sStr, sSubStr );
>
> } // end int ifind( in char[], in char[] )
>
>
> /*******************************************************************
> * Function      : int irfind( in char[], in char[] )
> * Author        : David L. 'SpottedTiger' Davis
> * Language      : DigitalMars "D" aka Mars v0.92
> * Created Date  : 03.Jun.04
> * Modified Date : 08.Jun.04 Removed the wrapper function and the
> *                           default parameter, mainly because the
> *                           string being passed in should be already
> *                           sliced so that the next search will find
> *                           the matching sub-string value. Also per
> *                           advice from Walter, <g> I've removed every
> *                           tolower() call, and now locally all characters
> *                           in the strings are set to lowercase where they
> *                           sit without the need to create a another copy.
> * Requirements  : std.string
> * Licence       : Same as those for the Phobos (Runtime Library)
> *******************************************************************
> *
> * Note: Meant to be a case insensitive version of std.string.rfind.
> */
> int irfind
> (
> in char[] sStr,
> in char[] sSubStr
> )
> {
> // If either of the string parameters are empty, return not found
> if ( sStr.length < 1 || sSubStr.length < 1 ) return -1;
>
> // sStr set to lowercase locally
> // lowercase ascii a = '\x61', uppercase ascii A = '\x41'
> foreach ( int iStrPos, char cChar; sStr )
> sStr[ iStrPos ] = ( find( uppercase, cChar ) != -1 ) ? sStr[ iStrPos ] +
0x20 :
> sStr[ iStrPos ];
>
> // sSubStr set to lowercase locally
> // lowercase ascii a = '\x61', uppercase ascii A = '\x41'
> foreach ( int iStrPos, char cChar; sSubStr )
> sSubStr[ iStrPos ] = ( find( uppercase, cChar ) != -1 ) ? sSubStr[
iStrPos ] +
> 0x20 : sSubStr[ iStrPos ];
>
> return rfind( sStr, sSubStr );
>
> } // end int irfind( in char[], in char[] )
>
> // Test ifind() and irfind() to find multiples of the same sub-string
> int main()
> {
>
> int    iStrPos   = 0;
> int    iSlicePos = 0;
> char[] sStrTest  = "ApO 123355 PO Box 23, Waterpool Street Portland,
Texas";
>
> printf( "Original = %.*s\n", sStrTest );
>
> iStrPos   = 0;
> iSlicePos = 0;
>
> while ( iSlicePos != -1 )
> {
> iSlicePos = ifind( sStrTest[ iStrPos .. sStrTest.length - 1 ], "PO" );
>
> if ( iSlicePos != -1 )
> {
> printf( "Found \'PO\' at position with ifind()= %d\n", iStrPos +
iSlicePos );
> iStrPos = iStrPos + iSlicePos + "PO".length;
> }
> }
>
> printf("\n\n");
>
> iStrPos  = sStrTest.length - 1;
> iSlicePos = 0;
>
> while ( iSlicePos != -1 && iStrPos >= 0 )
> {
> iSlicePos = irfind( sStrTest[ 0 .. iStrPos ], "PO" );
>
> if ( iSlicePos != -1 )
> {
> printf( "Found \'PO\' at position with irfind()= %d\n", iSlicePos );
> iStrPos = iSlicePos - "PO".length;
> }
> }
>
> return 0;
>
> } // end int main()
>
> -------------------------------------------------------------------
> "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
>
>
>


June 08, 2004
On Tue, 8 Jun 2004 14:56:32 -0700, Walter <newshound@digitalmars.com> wrote:
> The function uppercases the input string. It shouldn't modify its inputs.

A perfect example of where 'in' should mean 'const' and the compiler should catch this error.

Regan

> "David L. Davis" <SpottedTiger@yahoo.com> wrote in message
> news:ca54is$2h2r$1@digitaldaemon.com...
>> In article <ca4ot4$1sek$2@digitaldaemon.com>, Walter says...
>> >
>> >Thanks! I have some suggestions, though <g>. First, using toupper()
>> >allocates memory for the new string. While this works, it's better to
> avoid
>> >it if you can, i.e. just go through character by character and 
>> comparing
>> >that way. Second, I prefer to avoid a starting index; instead just 
>> slice
> the
>> >string to be searched. -Walter
>> >
>>
>> Walter: Ok, I think I've followed your suggestions correctly. :) Please
> let me
>> know if I've gotten it right, or if I'm off track somehow?
>>
>> import std.c.stdio;
>> import std.string;
>>
>> /*******************************************************************
>> * Function      : int ifind( in char[], in char[] )
>> * Author        : David L. 'SpottedTiger' Davis
>> * Language      : DigitalMars "D" aka Mars v0.92
>> * Created Date  : 03.Jun.04
>> * Modified Date : 08.Jun.04 Removed the wrapper function and the
>> *                           default parameter, mainly because the
>> *                           string being passed in should be already
>> *                           sliced so that the next search will find
>> *                           the matching sub-string value. Also per
>> *                           advice from Walter, <g> I've removed every
>> *                           tolower() call, and now locally all characters
>> *                           in the strings are set to lowercase where they
>> *                           sit without the need to create a another copy.
>> * Requirements  : std.string
>> * Licence       : Same as those for the Phobos (Runtime Library)
>> *******************************************************************
>> *
>> * Note: Meant to be a case insensitive version of std.string.find
>> */
>> int ifind
>> (
>> in char[] sStr,
>> in char[] sSubStr
>> )
>> {
>> // If either of the string parameters are empty, return not found
>> if ( sStr.length < 1 || sSubStr.length < 1 ) return -1;
>>
>> // sStr set to lowercase locally
>> // lowercase ascii a = '\x61', uppercase ascii A = '\x41'
>> foreach ( int iStrPos, char cChar; sStr )
>> sStr[ iStrPos ] = ( find( uppercase, cChar ) != -1 ) ? sStr[ iStrPos ] +
> 0x20 :
>> sStr[ iStrPos ];
>>
>> // sSubStr set to lowercase locally
>> // lowercase ascii a = '\x61', uppercase ascii A = '\x41'
>> foreach ( int iStrPos, char cChar; sSubStr )
>> sSubStr[ iStrPos ] = ( find( uppercase, cChar ) != -1 ) ? sSubStr[
> iStrPos ] +
>> 0x20 : sSubStr[ iStrPos ];
>>
>> return find( sStr, sSubStr );
>>
>> } // end int ifind( in char[], in char[] )
>>
>>
>> /*******************************************************************
>> * Function      : int irfind( in char[], in char[] )
>> * Author        : David L. 'SpottedTiger' Davis
>> * Language      : DigitalMars "D" aka Mars v0.92
>> * Created Date  : 03.Jun.04
>> * Modified Date : 08.Jun.04 Removed the wrapper function and the
>> *                           default parameter, mainly because the
>> *                           string being passed in should be already
>> *                           sliced so that the next search will find
>> *                           the matching sub-string value. Also per
>> *                           advice from Walter, <g> I've removed every
>> *                           tolower() call, and now locally all characters
>> *                           in the strings are set to lowercase where they
>> *                           sit without the need to create a another copy.
>> * Requirements  : std.string
>> * Licence       : Same as those for the Phobos (Runtime Library)
>> *******************************************************************
>> *
>> * Note: Meant to be a case insensitive version of std.string.rfind.
>> */
>> int irfind
>> (
>> in char[] sStr,
>> in char[] sSubStr
>> )
>> {
>> // If either of the string parameters are empty, return not found
>> if ( sStr.length < 1 || sSubStr.length < 1 ) return -1;
>>
>> // sStr set to lowercase locally
>> // lowercase ascii a = '\x61', uppercase ascii A = '\x41'
>> foreach ( int iStrPos, char cChar; sStr )
>> sStr[ iStrPos ] = ( find( uppercase, cChar ) != -1 ) ? sStr[ iStrPos ] +
> 0x20 :
>> sStr[ iStrPos ];
>>
>> // sSubStr set to lowercase locally
>> // lowercase ascii a = '\x61', uppercase ascii A = '\x41'
>> foreach ( int iStrPos, char cChar; sSubStr )
>> sSubStr[ iStrPos ] = ( find( uppercase, cChar ) != -1 ) ? sSubStr[
> iStrPos ] +
>> 0x20 : sSubStr[ iStrPos ];
>>
>> return rfind( sStr, sSubStr );
>>
>> } // end int irfind( in char[], in char[] )
>>
>> // Test ifind() and irfind() to find multiples of the same sub-string
>> int main()
>> {
>>
>> int    iStrPos   = 0;
>> int    iSlicePos = 0;
>> char[] sStrTest  = "ApO 123355 PO Box 23, Waterpool Street Portland,
> Texas";
>>
>> printf( "Original = %.*s\n", sStrTest );
>>
>> iStrPos   = 0;
>> iSlicePos = 0;
>>
>> while ( iSlicePos != -1 )
>> {
>> iSlicePos = ifind( sStrTest[ iStrPos .. sStrTest.length - 1 ], "PO" );
>>
>> if ( iSlicePos != -1 )
>> {
>> printf( "Found \'PO\' at position with ifind()= %d\n", iStrPos +
> iSlicePos );
>> iStrPos = iStrPos + iSlicePos + "PO".length;
>> }
>> }
>>
>> printf("\n\n");
>>
>> iStrPos  = sStrTest.length - 1;
>> iSlicePos = 0;
>>
>> while ( iSlicePos != -1 && iStrPos >= 0 )
>> {
>> iSlicePos = irfind( sStrTest[ 0 .. iStrPos ], "PO" );
>>
>> if ( iSlicePos != -1 )
>> {
>> printf( "Found \'PO\' at position with irfind()= %d\n", iSlicePos );
>> iStrPos = iSlicePos - "PO".length;
>> }
>> }
>>
>> return 0;
>>
>> } // end int main()
>>
>> -------------------------------------------------------------------
>> "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
>>
>>
>>
>
>



-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
June 08, 2004
In article <ca4r7l$20ig$1@digitaldaemon.com>, Arcane Jill says...
>
>In article <ca4ot4$1sek$2@digitaldaemon.com>, Walter says...
>(in response to David L. Davis)
>>
>>I have some suggestions, though <g>. First, using toupper()
>>allocates memory for the new string.
>
>(I'm actually replying to David here, not Walter)
>Another big problem with uppercasing the whole string is that it could be very
>slow. Imagine if the strings you were comparing were gigabytes long. Now imagine
>that the substring you were looking for could have been found right near the
>start of the string. Converting the case of all those gigs would have been
>unnecessary.
>
>Sorry to be a downer, but I learned this the hard way a couple of years ago. I actually managed to implement the whole Unicode case comparison algorithm for real, including special casing and everything. Man, was it S-L-O-W. (It casefolded everything before the compare even started). Then I optimized it by making look at only as much of the strings as it needed to, and after that it whizzed by.
>
>Jill
>
>

Jill: I just missed seeing your message before I posted the code again, sorry. But course you're right, if a very large string of data in passed in it's will slow things down a lot... darn, how in the heck did I miss that, cause I too have had to deal with a similar problem few years ago too.  :)

I think what it is, is with Walter giving me a half a chance to add something (no matter how small it may be) to the Phoboes.std library, is a real "Honor" and I don't want to blow it. :) Just knowing how very busy Walter is, I really appreciate him giving me this golden opportunity to contribute, and to feel a part of the "D" community.

I feel like a young Skywalker in training, learning how to best use "The Force!"


-------------------------------------------------------------------
"Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"