Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 31

Thread: "is" versus "<> nil" on speed?

  1. #21

    "is" versus "<> nil" on speed?

    Quote Originally Posted by JSoftware
    If that's correct then you are going to check if the pointer is nil anyways before using the "is" operator. Else you risk a heavy AV
    "is" includes a nil test and returns false in that case.
    ZGameEditor - Develop 64kb games for Windows.
    Thrust for Vectrex - ROM-file and 6809 source code.

  2. #22

    "is" versus "<> nil" on speed?

    Quote Originally Posted by VilleK
    Quote Originally Posted by JSoftware
    If that's correct then you are going to check if the pointer is nil anyways before using the "is" operator. Else you risk a heavy AV
    "is" includes a nil test and returns false in that case.
    I don't think so. My application crashes when I try the is operator on an uninitialized pointer

    edit: or atleast it did right before.. Now I can't reproduce it anymore
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  3. #23

    "is" versus "<> nil" on speed?

    Quote Originally Posted by JSoftware
    Quote Originally Posted by VilleK
    Quote Originally Posted by JSoftware
    If that's correct then you are going to check if the pointer is nil anyways before using the "is" operator. Else you risk a heavy AV
    "is" includes a nil test and returns false in that case.
    I don't think so. My application crashes when I try the is operator on an uninitialized pointer
    But if the pointer is uninitialized "is" will try to examine an instance that is void :? That's why it is crashing. When you use "is" with a pointer to nil, you get False.

  4. #24

    "is" versus "<> nil" on speed?

    Since we are all showing up our geniously designed code with awesome pointer wrestling or typecasting, let me share some of mine


    this calculates proper constant for sending wav raw wave data to openal:

    Code:
      format &#58;= AL_FORMAT_MONO8 + &#40;&#40;wavheader.BitsPerSample div 8&#41; - 1&#41; +
        &#40;wavheader.NumChannels - 1&#41; * 2;

    and a similar thing for opengl texture upload:

    Code:
         glTexImage2D&#40;GL_TEXTURE_2D, 0, 3 + integer&#40;&#40;format = GL_BGRA_EXT&#41; or &#40;format = GL_RGBA&#41;&#41;,
            Width, Height, 0, format, GL_UNSIGNED_BYTE, pData&#41;;
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  5. #25

    "is" versus "<> nil" on speed?

    Quote Originally Posted by cronodragon
    Quote Originally Posted by JSoftware
    Quote Originally Posted by VilleK
    Quote Originally Posted by JSoftware
    If that's correct then you are going to check if the pointer is nil anyways before using the "is" operator. Else you risk a heavy AV
    "is" includes a nil test and returns false in that case.
    I don't think so. My application crashes when I try the is operator on an uninitialized pointer
    But if the pointer is uninitialized "is" will try to examine an instance that is void :? That's why it is crashing. When you use "is" with a pointer to nil, you get False.
    My point exactly
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  6. #26

    "is" versus "<> nil" on speed?

    Why nobody had mentioned the Assigned() function? It is what is intended to check if an object/pointer is not nil in Pascal, *not* the "is" operator.
    Using "is" for that purpose is a big overkill. Its purpose is to check if the object A's class is equal to or descendant of the given class.

  7. #27

    "is" versus "<> nil" on speed?

    Quote Originally Posted by Chebmaster
    Why nobody had mentioned the Assigned() function?
    But I do mention it in my first post
    ZGameEditor - Develop 64kb games for Windows.
    Thrust for Vectrex - ROM-file and 6809 source code.

  8. #28
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    "is" versus "<> nil" on speed?

    cool , nice to know what is fastest ... for the if x<>nil then I mostly use if Assigned(x) then (however I THINK it's slower, but no sure...)
    NecroSOFT - End of line -

  9. #29

    "is" versus "<> nil" on speed?

    however I THINK it's slower, but no sure...
    Assigned(x) is a pseudo-function and the compiler generates the same code for it as for x<>nil

  10. #30
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    "is" versus "<> nil" on speed?

    no, it's different that x <> nil. I had some problems if I Assigned x and freed x, x was not nil! So I used if Assigned().
    NecroSOFT - End of line -

Page 3 of 4 FirstFirst 1234 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •