2868 #[1 2 3 1 2 3 1 2 19] max |
2867 #[1 2 3 1 2 3 1 2 19] max |
2869 #[] max |
2868 #[] max |
2870 " |
2869 " |
2871 ! |
2870 ! |
2872 |
2871 |
|
2872 startsWith:aByteOrByteArray |
|
2873 "return true, if the receiver starts with something, aStringOrChar. |
|
2874 If the argument is empty, true is returned. |
|
2875 Notice, that this is similar to, but slightly different from VW's and Squeak's beginsWith:, |
|
2876 which are both inconsistent w.r.t. an empty argument." |
|
2877 |
|
2878 %{ /* NOCONTEXT */ |
|
2879 int len1, len2; |
|
2880 REGISTER unsigned char *src1, *src2; |
|
2881 unsigned char c; |
|
2882 REGISTER OBJ slf = self; |
|
2883 |
|
2884 if (__qIsByteArrayLike(slf) &&__isByteArrayLike(aByteOrByteArray)) { |
|
2885 src1 = __byteArrayVal(slf); |
|
2886 src2 = __byteArrayVal(aByteOrByteArray); |
|
2887 |
|
2888 if (src1[0] != src2[0]) { |
|
2889 if (__qSize(aByteOrByteArray) == OHDR_SIZE) { |
|
2890 RETURN (true); |
|
2891 } |
|
2892 RETURN ( false ); |
|
2893 } |
|
2894 |
|
2895 len1 = __qSize(slf); |
|
2896 len2 = __qSize(aByteOrByteArray); |
|
2897 if (len1 < len2) { |
|
2898 RETURN ( false ); |
|
2899 } |
|
2900 |
|
2901 # ifdef UINT64 |
|
2902 while (len2 > (OHDR_SIZE+sizeof(UINT64))) { |
|
2903 if ( ((UINT64 *)src1)[0] != ((UINT64 *)src2)[0] ) { |
|
2904 RETURN (false); |
|
2905 } |
|
2906 len2 -= sizeof(UINT64); |
|
2907 src1 += sizeof(UINT64); |
|
2908 src2 += sizeof(UINT64); |
|
2909 } |
|
2910 # else |
|
2911 # ifdef __UNROLL_LOOPS__ |
|
2912 while (len2 > (OHDR_SIZE+sizeof(INT)*4)) { |
|
2913 if ( ((unsigned INT *)src1)[0] != ((unsigned INT *)src2)[0]) { |
|
2914 RETURN (false); |
|
2915 } |
|
2916 if ( ((unsigned INT *)src1)[1] != ((unsigned INT *)src2)[1]) { |
|
2917 RETURN (false); |
|
2918 } |
|
2919 if ( ((unsigned INT *)src1)[2] != ((unsigned INT *)src2)[2]) { |
|
2920 RETURN (false); |
|
2921 } |
|
2922 if ( ((unsigned INT *)src1)[3] != ((unsigned INT *)src2)[3]) { |
|
2923 RETURN (false); |
|
2924 } |
|
2925 len2 -= sizeof(INT)*4; |
|
2926 src1 += sizeof(INT)*4; |
|
2927 src2 += sizeof(INT)*4; |
|
2928 } |
|
2929 # endif /* __UNROLL_LOOPS__ */ |
|
2930 # endif /* UINT64 */ |
|
2931 |
|
2932 while (len2 > (OHDR_SIZE+sizeof(INT))) { |
|
2933 if ( ((unsigned INT *)src1)[0] != ((unsigned INT *)src2)[0]) { |
|
2934 RETURN (false); |
|
2935 } |
|
2936 len2 -= sizeof(INT); |
|
2937 src1 += sizeof(INT); |
|
2938 src2 += sizeof(INT); |
|
2939 } |
|
2940 |
|
2941 for ( ; len2 > (OHDR_SIZE+sizeof(INT)); len2++) { |
|
2942 if (*src1++ != *src2++) { |
|
2943 RETURN (false); |
|
2944 } |
|
2945 } |
|
2946 RETURN (true); |
|
2947 } |
|
2948 if (__isSmallInteger(aByteOrByteArray)) { |
|
2949 int val = __intVal(aByteOrByteArray); |
|
2950 if (__byteArraySize(slf) > 0) { |
|
2951 RETURN ( (__byteArrayVal(slf)[0] == val) ? true : false); |
|
2952 } |
|
2953 RETURN ( false ); |
|
2954 } |
|
2955 %}. |
|
2956 ^ super startsWith:aByteOrByteArray |
|
2957 |
|
2958 " |
|
2959 #[1 2 3 4 5 6 7 8 9 10] startsWith:#[ 1 2 3 4 5] |
|
2960 #[1 2 3 4 5 6 7 8 9 10] startsWith:#[ 0 1 2 3 4 5] |
|
2961 #[1 2 3 4 5 6 7 8 9 10] startsWith:#(1 2 3 4 5) |
|
2962 #[1 2 3 4 5 6 7 8 9 10] startsWith:1 |
|
2963 #[1 2 3 4 5 6 7 8 9 10] startsWith:2 |
|
2964 " |
|
2965 ! |
|
2966 |
2873 usageCounts |
2967 usageCounts |
2874 "return an array filled with value-counts - |
2968 "return an array filled with value-counts - |
2875 This is needed in the bitmap/image classes to get info on color usage. |
2969 This is needed in the bitmap/image classes to get info on color usage. |
2876 (i.e. to build up a histogram of color usage within an image)." |
2970 (i.e. to build up a histogram of color usage within an image)." |
2877 |
2971 |