Closed Bug 334167 Opened 18 years ago Closed 18 years ago

make NS_IsNativeUTF8 inline where it returns PR_TRUE/FALSE

Categories

(Core :: XPCOM, defect)

defect
Not set
trivial

Tracking

()

RESOLVED FIXED

People

(Reporter: jshin1987, Assigned: jshin1987)

Details

(Keywords: intl)

Attachments

(1 file)

On OS X and BeOS, NS_IsNativeUTF8 always returns PR_TRUE while on Windows and OS2, it always returns PR_FALSE. Now that we really begin to use the function (e.g. bug  333703), we'd better make it inline on those platforms.
Attached patch patchSplinter Review
this is a simple patch to avoid macros as defined attachment 218455 [details] [diff] [review] (bug 333703)
Attachment #218562 - Flags: superreview?(darin)
Attachment #218562 - Flags: review?(darin)
Comment on attachment 218562 [details] [diff] [review]
patch

>Index: xpcom/io/nsNativeCharsetUtils.h

>+#if defined(XP_UNIX) && !defined(XP_MACOSX)
> NS_COM PRBool NS_IsNativeUTF8();
>+#else
>+inline NS_COM PRBool NS_IsNativeUTF8()
>+{
>+#if defined(XP_MACOSX) || defined(XP_BEOS)
>+    return PR_TRUE;
>+#else
>+    return PR_FALSE;
>+#endif
>+}
>+#endif

In the inline case, you should remove NS_COM.  That macro introduces
things like declspec(dllexport/dllimport) on Windows, and I think we
don't want that in this case.

Also, could you please add a /** ... */ comment block description to
this function.

r+sr=darin
Attachment #218562 - Flags: superreview?(darin)
Attachment #218562 - Flags: superreview+
Attachment #218562 - Flags: review?(darin)
Attachment #218562 - Flags: review+
thanks for r/sr
checked into the trunk (a day ago) with the following rather long comment :

/* 
 * This function indicates whether the character encoding used in the file
 * system (more exactly what's used for |GetNativeFoo| and |SetNativeFoo|
 * of |nsILocalFile|) is UTF-8 or not. Knowing that helps us avoid an 
 * unncessary encoding conversion in some cases. For instance, to get the leaf
 * name in UTF-8 out of nsILocalFile, we can just use |GetNativeLeafName| rather
 * than using |GetLeafName| and converting the result to UTF-8 if the file 
 * system  encoding is UTF-8.
 * On Unix (but not on Mac OS X), it depends on the locale and is not known
 * in advance (at the compilation time) so that this function needs to be 
 * a real function. On Mac OS X and BeOS, it's always UTF-8 while on Windows 
 * and other platforms (e.g. OS2), it's never UTF-8.  
 */
                                                                                

	

                                                              
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
I also got rid of NS_COM for the inline case.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: