Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

minor cleanup in websocket code

Aperta
#210 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Ferma

Direzione di ricerca

Inizia leggendo aws-net-websocket-registry.adb e la gestione delle eccezioni circostante della procedura Watch. Confronta l'inserimento proposto di una singola ricerca con il comportamento attuale, in particolare se Unregister debba rimanere e in quale stato venga lasciato Watched in caso di errore. Il lavoro è completato quando la ricerca non è duplicata e il comportamento delle eccezioni è coerente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

While reviewing code for PR 209, I noticed the following function aws-net-websocket-registry.adb:

      procedure Watch (WebSocket : Object_Class) is
      begin
         if Is_Registered (WebSocket.Id)
           and then not Watched.Contains (WebSocket.Id)
         then
            Watched.Insert (WebSocket.Id);
            Count := Count + 1;
            Signal_Socket;
         end if;

      exception
         when others =>
            Unregister (WebSocket);
            raise;
      end Watch;

It is slightly un-optimal since it needs to do two lookups when the socket is not watched yet. Perhaps something like the following would be more efficient:

      procedure Watch (WebSocket : Object_Class) is
          Inserted : Boolean;
          Pos : WebSocket_Set.Cursor;
      begin
         if Is_Registered (WebSocket.Id) then
            Watched.Insert (WebSocket.Id, Pos, Inserted);
            if Inserted then
               Count := Count + 1;
               Signal_Socket;
            end if;
        end if;

      exception
         when others =>
            --  ??? Not clear why we would unregister the socket here ? 
            --  also, it is possible that it is still in Watched at this point, and given the first test in this procedure this
            --  might be unexpected behavior.
            Unregister (WebSocket);
            raise;
      end Watch;
Lingua principale
Ada
Stelle
162
Fork
45
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AdaCore/aws

Tutte le issue di AdaCore/aws

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.