1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Forms

Discussion in 'Development' started by Angel, Apr 8, 2019.

  1. Angel

    Angel Spider Jockey

    Messages:
    44
    GitHub:
    aimjel
    Quick question. Is it bad to save a Form's instance to send it to another or many other players?
     
  2. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
  3. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    By save, I guess you're meaning cache and not serialize it as an object instance. Anyway, with all the form APIs floating around, it's hard to make a judgement. If you're using pocketmine's Form class, feel free to reuse the same instance.
     
  4. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    pocketmine\form\Form itself does not have any restriction on using the instance, but there might be other effects depending on the forms library you use.
    In particular, there may be race condition if you send the same form to the same player several times.
     
  5. Angel

    Angel Spider Jockey

    Messages:
    44
    GitHub:
    aimjel
    The form is being used to teleport to places. I also plan to have a good 35 players, so I don't know if creating a new instance or reusing the same instance will have any impact on the server performance because when you join the server you have to pick from the form.
     
  6. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Unless you are doing it like 100000 times per second, creating new objects has no impact on performance.
     
    Angel likes this.
  7. Angel

    Angel Spider Jockey

    Messages:
    44
    GitHub:
    aimjel
    Thanks.
     
  8. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    In case anyone is really paranoid, 100000 is just a random number I typed. Don't take this number seriously and count how many times you construct objects and compare with this seriously.
    In short, don't premature optimize unless you are sure it has a problem or if there is a very simple fix that does not affect more than 2 lines of code.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.